Some users would like to auto record the information of the attachments in every incoming email. This article will share a quick time to realize it with ease.
If you are accustomed to exporting the attachment information of each incoming Outlook email to an Excel file, perhaps you’ll long for some approaches that can let Outlook auto undertake this work. Thereby, you’re able to get rid of tracking attachments manually. Fortunately, though Outlook doesn’t provide such a direct feature, you still can achieve it with a bit of scripting. Now, we will teach you step by step.
Auto Export the Attachment Information of Incoming Emails to Excel
- At first, launch Outlook application.
- Then, go to VBA editor via “Alt + F11”.
- Next, copy the following VBA code into a module.
Sub AutoExportAttachmentInfo(objMail As Outlook.MailItem) Dim objExcelApp As Excel.Application Dim objExcelWorkbook As Excel.Workbook Dim objExcelWorksheet As Excel.Worksheet Dim nLastRow As Integer Dim objAttachment As Outlook.Attachment If objMail.Attachments.Count > 0 Then 'Change the path to the specific Excel file strExcelFile = "E:\Attachment Info.xlsx" Set objExcelApp = CreateObject("Excel.Application") objExcelApp.Visible = True Set objExcelWorkbook = objExcelApp.Workbooks.Open(strExcelFile) Set objExcelWorksheet = objExcelWorkbook.Sheets("Sheet1") 'Export Attachment info to Excel For Each objAttachment In objMail.Attachments nLastRow = objExcelWorksheet.Range("A" & objExcelWorksheet.Rows.Count).End(xlUp).Row + 1 With objExcelWorksheet .Cells(nLastRow, 1) = objMail.Subject .Cells(nLastRow, 2) = objMail.SenderEmailAddress .Cells(nLastRow, 3) = objAttachment.FileName .Cells(nLastRow, 4) = objMail.ReceivedTime End With Next objExcelWorksheet.Columns("A:C").AutoFit objExcelWorkbook.Close True objExcelApp.Quit End If End Sub
- After that, exit VBA editor.
- Subsequently, create a rule to auto run this macro on every incoming email.
- First off, go to “File” menu.
- Then, click “Manage Rules & Alerts” button.
- In the “Rules and Alerts” dialog box, click “New Rule”.
- In the “Rule Wizard” dialog box, select “Apply rule on messages I receive” and click “Next”.
- Next, set rule conditions as per your needs and hit “Next”.
- In the “Select Actions” step, select “Run a script” and choose “AutoExportAttachmentInfo” script.
- Finally, follow onscreen wizards to finish rule setup.
- From now on, every time when a new email arrives in your mailbox, if it has any attachments, Outlook will auto export the attachment information to the predefined Excel file.
Never Download Suspicious Attachments
Have you ever received any emails that are from unknown senders and contain attachments? Usually, it is suggested not to readily trust in such attachments in that they may be with viruses. As long as you download them, your Outlook data can be infected. At that point, you’ll need to fix Outlook file. It’s admittedly knotty unless you resort to a proficient repair tool, such as DataNumen Outlook Repair.
Author Introduction:
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including recover Sql Server and outlook repair software products. For more information visit www.datanumen.com