P
Patrick
Please help I spent way to much time trying to figure this
one out.
I created a module to cycle through my inbox and then save
any attachments with extension .aud .swb .a2k. to a
directory folder.
Their is nothing wrong with the code. The issue is that
outlook says some of these messages contain an extra
attachment then what I see. i.e. I physically see 2
attachments but outlook see's 3. Then my code fails
because outlook says it cannot do this of action on this
type of attachment.
Does anyone know why this is?
Here is my code, I am positive it is correct because it
works when it does not encounter a message with this
problem of hidden attachments.
Sub SaveAttachment()
Dim iAttachCnt As Integer
Dim olns As Outlook.NameSpace
Dim oAttachments As Outlook.Attachments
Dim ol As Outlook.Application
Dim message As Object
Dim iTotalAttachSave As Integer
Set ol = New Outlook.Application
Set olns = ol.GetNamespace("MAPI")
Set myFolder = olns.Folders("My Personal Folder") 'Name of
Main Folder where inbox is included, folder name is case
sensitive.
Set myFolder2 = myFolder.Folders("Inbox").Items 'Inbox name
For Each message In myFolder2
With message.Attachments
If iAttachCnt > 0 Then
For iCtr = 1 To iAttachCnt
If .Item(iCtr).FileName Like "*.A2K" Or _
.Item(iCtr).FileName Like "*.SWB" Or _
.Item(iCtr).FileName Like "*.AUD" Then
MsgBox .Item(iCtr).FileName
.Item(iCtr).SaveAsFile "U:\TSG\EXT\AWU\" _
& .Item(iCtr).FileName
'Get the total # of attachments added
iTotalAttachSave = 1 + iTotalAttachSave
End If
Next iCtr
End If
End With
Next message
MsgBox "You have added " & iTotalAttachSave & "
attachments to U:\TSG\Ext\AWU\"
'Clear variables
Set message = Nothing
Set oFldr = Nothing
Set olns = Nothing
Set ol = Nothing
Set myFolder2 = Nothing
Set myFolder = Nothing
End Sub
..
one out.
I created a module to cycle through my inbox and then save
any attachments with extension .aud .swb .a2k. to a
directory folder.
Their is nothing wrong with the code. The issue is that
outlook says some of these messages contain an extra
attachment then what I see. i.e. I physically see 2
attachments but outlook see's 3. Then my code fails
because outlook says it cannot do this of action on this
type of attachment.
Does anyone know why this is?
Here is my code, I am positive it is correct because it
works when it does not encounter a message with this
problem of hidden attachments.
Sub SaveAttachment()
Dim iAttachCnt As Integer
Dim olns As Outlook.NameSpace
Dim oAttachments As Outlook.Attachments
Dim ol As Outlook.Application
Dim message As Object
Dim iTotalAttachSave As Integer
Set ol = New Outlook.Application
Set olns = ol.GetNamespace("MAPI")
Set myFolder = olns.Folders("My Personal Folder") 'Name of
Main Folder where inbox is included, folder name is case
sensitive.
Set myFolder2 = myFolder.Folders("Inbox").Items 'Inbox name
For Each message In myFolder2
With message.Attachments
If iAttachCnt > 0 Then
For iCtr = 1 To iAttachCnt
If .Item(iCtr).FileName Like "*.A2K" Or _
.Item(iCtr).FileName Like "*.SWB" Or _
.Item(iCtr).FileName Like "*.AUD" Then
MsgBox .Item(iCtr).FileName
.Item(iCtr).SaveAsFile "U:\TSG\EXT\AWU\" _
& .Item(iCtr).FileName
'Get the total # of attachments added
iTotalAttachSave = 1 + iTotalAttachSave
End If
Next iCtr
End If
End With
Next message
MsgBox "You have added " & iTotalAttachSave & "
attachments to U:\TSG\Ext\AWU\"
'Clear variables
Set message = Nothing
Set oFldr = Nothing
Set olns = Nothing
Set ol = Nothing
Set myFolder2 = Nothing
Set myFolder = Nothing
End Sub
..