Skip to main content

Save Attachments in Outlook automatically

For years I have wanted something to do this, and finally found it.

Worked perfectly for me in Outlook 2013 

In the end it is so simple.

Guide from
http://www.pixelchef.net/content/rule-autosave-attachment-outlook

and
https://msdn.microsoft.com/en-us/library/ee814736.aspx

  1. Open the VBA IDE in Outlook. Alt-F11 will do this.
  2. Insert the following code to the Modules section. On the left side there is a tree, expand until you find Modules. Then, if there is not a Module item under Modules, create one by right clicking on Modules. Or right click and choose Insert -> Module.
  3. Now, paste the text below in the main VBA window.
  4. Close the VBA IDE.
  5. Create a Rule that calls the script. Tools -> Rules and Alerts -> New Rule...
  6. In the first screen of the new rule wizard, choose "Check messages when they arrive".
  7. In the second, you could specify certain criteria that the message must match. Tip: Try "with specific words in the message header" and ".txt" for the search string to save only .txt files.
  8. On the third screen, choose "run a script". When you click the underlined word, "script", you should see the code that you pasted in the VBA console.
  9. Click "finish", and test your work.

The code

Public Sub saveAttachtoDisk (itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "c:\temp\"


Dim rcdDate
rcdDate = Format(itm.ReceivedTime, "yyyymmddHhmmSs")


     For Each objAtt In itm.Attachments       
          objAtt.SaveAsFile saveFolder & "\" &
rcdDate & "_" & objAtt.DisplayName       
          Set objAtt = Nothing   
     Next
End Sub






Comments

Popular posts from this blog

Javascript Form Validation

It's real simple. All you need to do is call a javascript function in a html  " onsubmit " in the form tag as a javascript return, like this       <form method="post" action="dosomething.php" onsubmit="return validateForm();"> If the code completes ok, the form is then sent to the page listed in "action" http://www.w3schools.com/js/js_form_validation.asp If the function specified in the onsubmit returns false, then the form is not sent to the page mentioned in action.