-2

I need to write an Outlook macro that saves attachments from mails which have specified title beginnings (for example: "Report..") OR have specified senders. I haven't programmed in Outlook VBA, so i don't know how to begin. Can you help?

2

1 Answer 1

0

I believe this will do what you want.

Sub SetFlagIcon()

Const olFolderInbox = 6

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)

Set colItems = objFolder.Items

For Each objMessage In colItems
If objMessage.SenderEmailAddress = "[email protected]" Then
    intCount = objMessage.Attachments.Count
    If intCount > 0 Then
        For i = 1 To intCount
            objMessage.Attachments.Item(i).SaveAsFile "C:\your_path_here\Desktop\" & _
                objMessage.Attachments.Item(i).FileName
        Next
    End If
End If
Next

End Sub

Please see the links below for some other ideas of where to go with this.

https://www.extendoffice.com/documents/outlook/3747-outlook-auto-download-save-attachments-to-folder.html

https://www.pixelchef.net/content/rule-autosave-attachment-outlook

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.