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
- In the first place, you should launch your Outlook application.
- After entering Outlook, press “Alt + F11” key shortcuts to open VBA editor.
- Then in the popup “Microsoft Visual Basic for Applications” window, you can insert a new module by clicking “Insert” > “Module”.
- 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" Next End If End If Next '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
- After that, you can close the VBA editor.
- And then add the new VBA project to Quick Access Toolbar as usual.
- Later you should change your Outlook macro security level to low.
- 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:
- 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.
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.
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 www.datanumen.com