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.
.

 

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