At times, you may want to quickly remove a specific type of attachments from many Outlook emails, such as removing the .exe attachments to block viruses. In this case, you can use the method exposed in this article, which is pretty convenient.
Many users long for a solution to batch remove a specific type of attachments from multiple emails in Outlook. For example, to prevent valuable Outlook data from viruses or malware, you should not open the suspicious attachments, such as .exe attachments. Hence, if you hope to bulk delete the .exe attachments from multiple emails, you can use the following means to get it in a jiffy.
Remove a Specific Type of Attachments from Multiple Emails
- For a start, launch your Outlook program.
- Then, access Outlook VBA editor with reference to the article – “How to Run VBA Code in Your Outlook”.
- Next, in the “Microsoft Visual Basic for Applications” window, copy and paste the VBA code below into a project or module.
Sub RemoveSpecificTypeOfAttachments() Dim objSelection As Outlook.Selection Dim i, n As Long Dim objMail As Outlook.MailItem Dim objAttachment As Outlook.Attachment Dim strFileType As String 'Get the selected emails Set objSelection = Outlook.Application.ActiveExplorer.Selection 'Process each email one by one For i = objSelection.Count To 1 Step -1 If TypeOf objSelection(i) Is MailItem Then Set objMail = objSelection(i) If objMail.Attachments.Count > 0 Then For n = objMail.Attachments.Count To 1 Step -1 Set objAttachment = objMail.Attachments.Item(n) 'Get the attachment file type strFileType = Right(objAttachment.FileName, Len(objAttachment.FileName) - InStr(1, objAttachment.FileName, ".")) 'Delete the specific type of attachments Select Case strFileType Case "exe" objAttachment.Delete Case Else End Select Next objMail.Save End If End If Next i End Sub
- After that, exit the current window.
- Later, for convenient access, you’re better off adding the new macro to Quick Access Toolbar.
- Eventually, you could try this macro right now.
- In the first place, select the source emails from which you want to delete a specific type of attachments.
- Then, click the macro button in Quick Access Toolbar.
- When macro completes, you can recheck these emails. All of the specific type of attachments must have been deleted.
Retrieve Lost Outlook Data
When Outlook crashes and its data is lost, Scanpst, the inbuilt free tool, will occur to most users’ mind in the first place. Nevertheless, to be honest, it cannot come into obvious effects in face of such serious problems. At worst, not only will it be unable to fix the issues, but also it may make further damage to Outlook file. Thus, in fact, it’s always advisable to apply a more experienced and trusty external PST repair tool, such as DataNumen Outlook Repair.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including recover sql and outlook repair software products. For more information visit www.datanumen.com