How to Batch Save All the Attachments in a Specific Conversation with Outlook VBA

If you want to extract and save all the email attachments in a specific conversation, you can use the method introduced in this article, which will help you achieve it in quick time with Outlook VBA.

It is inevitable that your mailbox in Outlook must contain multiple conversations. An email conversation refers to an email thread, which includes the original mail, forwarding mails as well as replies. Therefore, the emails in one conversation are interrelated. Perhaps they are involved with an important work program. Hence, at times, you may desire to save all the attachments in a specific conversation to a certain local folder. Undoubtedly, saving one by one will be quite cumbersome. So here we will introduce you a quick means via Outlook VBA.

Batch Save All the Attachments in a Specific Conversation

Batch Save All the Attachments in a Specific Conversation

  1. In the first place, you should launch your Outlook application.
  2. After entering Outlook, press “Alt + F11” key shortcuts to open VBA editor.
  3. Then in the popup “Microsoft Visual Basic for Applications” window, you can insert a new module by clicking “Insert” > “Module”.
  4. Subsequently, you should copy the following VBA codes into the new module.
Sub SaveAllAttachmentsinSpecificConversation()
    Dim objSelectedItem As Object
    Dim objMail As Outlook.MailItem
    Dim objConversation As Outlook.Conversation
    Dim objConversationMail As Outlook.MailItem
    Dim objAttachments As Outlook.attachments
    Dim objAttachment As Outlook.Attachment
    Dim i As Long
    Dim strAttachmentList As String
    Dim objFileSystem As Object
    Dim objTextFile As Object

    Set objSelectedItem = Application.ActiveExplorer.Selection.Item(1)

    If TypeOf objSelectedItem Is MailItem Then
       Set objMail = objSelectedItem
       Set objConversation = objMail.GetConversation

       If Not (objConversation Is Nothing) Then
          For Each objConversationMail In objConversation.GetRootItems
              If TypeOf objConversationMail Is MailItem Then
                 Set objAttachments = objConversationMail.attachments
                 If objAttachments.Count > 0 Then
                    For Each objAttachment In objAttachments
                        'Change saving folder path as per your actual case
                        objAttachment.SaveAsFile "C:\Attachments\Test Conversation\" & objAttachment.DisplayName
                        strAttachmentList = strAttachmentList & vbCrLf & vbCrLf & " - " & objAttachment.DisplayName & vbTab & objAttachment.Size & " KB"
                 End If
              End If
         'Record the information of the attachments of this conversation in a TXT file
         Set objFileSystem = CreateObject("Scripting.FileSystemObject")
         Set objTextFile = objFileSystem.CreateTextFile("C:\Attachments\Test Conversation\Conversation - " & objMail.ConversationTopic & ".txt", True)
         objTextFile.WriteLine (strAttachmentList)
         MsgBox ("All Attachments Get Saved!") 
      End If
    End If
End Sub

VBA Codes - Batch Save All the Attachments in a Specific Conversation

  1. After that, you can close the VBA editor.
  2. And then add the new VBA project to Quick Access Toolbar as usual.Add the new VBA project to Quick Access Toolbar
  3. Later you should change your Outlook macro security level to low.
  4. Finally, you can try this new macro by following the steps below.
  • Firstly, select an email.
  • Then click the new macro button in Quick Access Toolbar.
  • At once, if succeed, you will receive an message:Message Prompting Attachments Saved Successfully
  • Lastly, you can go to the predetermined saving folder. Over there you will see all the attachments in this conversation and a TXT file recording the information of the attachments.Attachments get saved in the predetermined saving folder

Protect Your Mails from Corruption

Although Outlook is boasting of a lot of features, you still should keep cautious as it’s susceptible to damage. First of all, to safeguard your Outlook data, you need to make regular backups. Moreover, it is also suggested to keep a robust Outlook recovery tool in vicinity, such as DataNumen Outlook Repair, which will be able to come to your rescue as soon as you encounter unexpected Outlook corruption.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including SQL Server fix and outlook repair software products. For more information visit

Comments are closed.