Check the box for (the version number may vary based on your Office suite). 2. Set Your Save Path
Sub DownloadAttachmentsFromOutlook() Dim OutlookApp As Outlook.Application Dim OutlookNamespace As Namespace Dim Folder As MAPIFolder Dim OutlookItem As Object Dim Attachment As Attachment Dim SavePath As String Dim FileName As String ' Set your save destination here (ensure the folder exists) SavePath = "C:\Users\YourName\Documents\SavedAttachments\" Set OutlookApp = New Outlook.Application Set OutlookNamespace = OutlookApp.GetNamespace("MAPI") ' This targets the default Inbox. ' Use OutlookNamespace.GetDefaultFolder(olFolderInbox).Folders("YourFolderName") for subfolders. Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox) For Each OutlookItem In Folder.Items ' Check if the item is a MailItem If TypeName(OutlookItem) = "MailItem" Then If OutlookItem.Attachments.Count > 0 Then For Each Attachment In OutlookItem.Attachments FileName = SavePath & Attachment.DisplayName ' Save the attachment Attachment.SaveAsFile FileName Debug.Print "Saved: " & Attachment.DisplayName Next Attachment End If End If Next OutlookItem MsgBox "Download Complete!", vbInformation End Sub Use code with caution. Key Configuration Steps 1. Enable Reference Libraries vba code to download attachments from outlook
Use a Dir() function check to see if a file already exists in the folder before saving to prevent errors. Check the box for (the version number may
Use If Right(Attachment.FileName, 4) = ".pdf" Then to ignore images in signatures and only grab PDF documents. ' Use OutlookNamespace
To use this, open Outlook, press Alt + F11 to open the VBA Editor, go to Insert > Module , and paste the following: