I receive an email with two images in the email body as part of the signature and two files in the attachment.
How do I just save the two files in the attachment (green arrows) and ignore the other two files in the email body (the red arrows). Like this option of Outlook itself does:
Checking if the attachment is .gif or .png or .jpg is unfortunately not an option. We do receive these type of files as attachment we want to save.
Thanks in advance for the support!
This is the code I use. But it saves also the (image)files from the email body.
Sub SaveAttachments()
Dim myOlApp As Outlook.Application
Dim myInspector As Outlook.Inspector
Dim myItem As Outlook.mailItem
Dim myAttachments As Outlook.Attachments
Set myOlApp = CreateObject("Outlook.Application")
Set myInspector = myOlApp.ActiveInspector
If Not TypeName(myInspector) = "Nothing" Then
If TypeName(myInspector.CurrentItem) = "MailItem" Then
Set myItem = myInspector.CurrentItem
Set myAttachments = myItem.Attachments
'Prompt the user for confirmation
Dim strPrompt As String
strPrompt = "Do you want to save the attachments..."
If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
For Each att In myAttachments
'[saving the attachment]
Next att
MsgBox "Attachments are saved"
End If
Set myAttachments = Nothing
Set myItem = Nothing
Else
MsgBox "Only email attachments can be saved."
End If
Set myInspector = Nothing
End If
Set myOlApp = Nothing
End Sub