
After running the code, a dialog will pop up to remind you whether to replace the duplicate attachments, choose Yes or No based on your needs.
#Postbox how to save emails to computer code#
XYesNo = MsgBox("The file is exists, do you want to replace it", vbYesNo + vbInformation, "Kutools for Outlook")Ģ) If you want to check for duplicate attachment names, please apply the VBA code 2. VBA code 2: Bulk save attachments from multiple emails (check for duplicates) Public Sub SaveAttachments() If xItem.BodyFormat olFormatHTML Then Exit Function XPath = xFso.GetParentFolderName(GFilepath) & "\" & xFso.GetBaseName(GFilepath) & " " & GCount & "." + xFso.GetExtensionName(GFilepath)įunction IsEmbeddedAttachment(Attach As Attachment) Set xFso = CreateObject("Scripting.FileSystemObject") XMailItem.HTMLBody = "" & "The file(s) were saved to " & xSaveFiles & "" & xMailItem.HTMLBodyįunction FileRename(FilePath As String) As String XMailItem.Body = vbCrLf & "The file(s) were saved to " & xSaveFiles & vbCrLf & xMailItem.Body XSaveFiles = xSaveFiles & "" & "" & xFilePath & "" If xMailItem.BodyFormat olFormatHTML Then XAttachments.Item(i).SaveAsFile xFilePath If IsEmbeddedAttachment(xAttachments.Item(i)) = False Then XFilePath = xFolderPath & xAttachments.Item(i).FileName If VBA.Dir(xFolderPath, vbDirectory) = vbNullString Then XFolderPath = xFolderPath & "\Attachments\" XFolderPath = CreateObject("WScript.Shell").SpecialFolders(16) Dim GCount As Integerĭim xFilePath As String, xFolderPath As String, xSaveFiles As String Tips: This code will save exact same name attachments by adding digits 1, 2, 3.after file names. VBA code 1: Bulk save attachments from multiple emails (save exact same name attachments directly) Click Insert > Module to open the Module window, and then copy one of the following VBA code into the window. Select the emails which the attachments you will save, and then press Alt + F11 keys to open the Microsoft Visual Basic for Applications window.ģ. Get into the Documents folder and create a folder named “Attachments”.

Firstly, you need to create a folder for saving the attachments in your computer. This section demonstrates a VBA code in a step-by-step guide to help you quickly save all attachments from multiple emails to a specific folder at once. Several clicks to save all attachments from multiple emails to folder with an amazing tool Save all attachments from multiple emails to folder with VBA code In this article, we introduce two methods for you to bulk save all attachments from multiple emails to a specific folder easily in Outlook. You need to repeatedly apply the Save All Attachments feature in each email until all attachments are saved from those emails. However, if you want to save all attachments from multiple emails at once, there is no direct feature can help. It is easy to save all attachments from an email with the build-in Save All Attachments feature in Outlook. How to save all attachments from multiple emails to folder in Outlook?
