C
Cue
Hi,
I'm trying to save an Excel attachment from an email in Outlook using vba. I
keep getting the error code 'Type Mismatch' for the line with the * next to
it.
Sub SaveAttachments()
Dim myOlapp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myItem As Outlook.MailItem
Dim myAttachment As Outlook.Attachment
'Dim I As Long
Set myOlapp = CreateObject("Outlook.Application")
Set myNameSpace = myOlapp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myFolder = myFolder.Folders("ADJUSTMENTS")
*Set myAttachment = myFolder.Items
For Each myItem In myFolder.Items
If myAttachment.FileName = "QAZ.xls" Then
myAttachment.SaveAsFile "C:\MailTest\Att.xls"
End If
Next
End Sub
Can anyone show me what it should be or what I am doing wrong?
Thanks!
I'm trying to save an Excel attachment from an email in Outlook using vba. I
keep getting the error code 'Type Mismatch' for the line with the * next to
it.
Sub SaveAttachments()
Dim myOlapp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myItem As Outlook.MailItem
Dim myAttachment As Outlook.Attachment
'Dim I As Long
Set myOlapp = CreateObject("Outlook.Application")
Set myNameSpace = myOlapp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myFolder = myFolder.Folders("ADJUSTMENTS")
*Set myAttachment = myFolder.Items
For Each myItem In myFolder.Items
If myAttachment.FileName = "QAZ.xls" Then
myAttachment.SaveAsFile "C:\MailTest\Att.xls"
End If
Next
End Sub
Can anyone show me what it should be or what I am doing wrong?
Thanks!