VBA Save All Outlook Attachments

VBA Save All Outlook Attachments

VBA to save all outlook email attachments.  Change Set myFolder = myNamespace.Folders.Item(“Dylan.Gregory@vba-market.com”).Folders(“Inbox”) to your outlook email folder path.
.

VBA Save All Outlook Attachments

Dim myAttachments As Outlook.Attachments
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNamespace.Folders.Item("Dylan.Gregory@vba-market.com").Folders("Inbox")
'myFolder.Display

itemsCount = myFolder.Items.Count
i = 0
For i = 1 To itemsCount
Set myItem = myFolder.Items(i)
myItem.Display

Set myAttachments = myItem.Attachments
If myItem.Attachments.Count > 0 Then
ipath = "Z:\Dylan\attachments\"
On Error Resume Next
myAttachments.Item(i).SaveAsFile ipath & myAttachments.Item(i).DisplayName
' MsgBox myAttachments.Item(i).DisplayName & " has been saved to " & ipath
On Error GoTo 0

End If
[efb_likebox fanpage_url="https://www.facebook.com/vbamarket/" box_width="840" box_height=340"" responsive="1" show_faces="1" show_stream="1" hide_cover="1" small_header="0" hide_cta="0" locale="en_US"]