IT, Microsoft

Scrip to Automatically Download Attachments from Outlook


If you are one of those people who is too lazy to download attachments from their email (me!), this script is perfect for you!

All you need is:

  • A machine that is constantly running
  • Microsoft Outlook

Let’s get to it:

For this example, I am going download/save “Outside Pittsburgh IP Alert” log reports that are sent from “Administrator” to my email on a daily basis. These reports will be saved in C:\Users\anindayu.pradetha\Downloads\Log Report\

  1. Go to Visual Basic in the Developer tab or press Alt + F11.
  2. Click Insert > Module and paste the VB script below into the Module window:
    Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)Dim oAttachment As Outlook.Attachment
    Dim sSaveFolder As String
    sSaveFolder = “C:\Users\anindayu.pradetha\Downloads\Log Report\”
    For Each oAttachment In MItem.Attachments
    oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
    NextEnd Sub

    Note: Replace “C:\Users\anindayu.pradetha\Downloads\Log Report\” with the path of the destination folder that you desire.

  3. Save the script and close the VB window.
  4. In the Home tab, click Rules > Management Rules & Alerts.


  5. Then, click New Rule button on the E-mail Rules tab.


  6. In the Rules Wizard box, select Apply rule on messages I receive, and click Next.


  7. In the (Which condition(s) do you want to check?) dialog box, check any option that applies to you. In my case, to ensure that the attachments from all emails that are entitled “Outside Pittsburgh IP Alert” and sent by Administrator will be saved in the desired folder, I will check with specific words in the sender’s address and with specific words in the subject or body and add the specific words for each option. Click Next when you are done.

  8. In the (What do you want to do with the message?) dialog box, check the run a script option, select the a script option, and add Project1.SaveAttachmentsToDisk. Then, click Next.

    Can’t find the “run a script” option? Visit this page for more info on how to enable the option.

  9. In the (Are there any exceptions?) dialog box, click Next.

  10. In the last dialog box, name the rule that you desire. check Run this rule now on messages already in “Inbox” and Turn on this rule options, and click Finish.


  11. Close the Rules and Alerts dialog box.

Tada! Now all attachments from emails that are sent from Administrator with the subject Outside Pittsburgh IP Alert will be saved directly to the specified destination folder.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s