This morning I had a very interesting query from a user. The request was if he could auto-download all the attachments that he received on his Outlook to another folder other than the temporary one (default folder). I sat down for a while looking for rules or any option on Outlook itself. But nothing to be found. When I did a bit of my own research, I figured out that with a bit of coding and then using the Outlook Rules itself, this was possible.
The link found to be very helpful for this purpose. Please note that in the section where one can specify the file type that needs to be stored to the custom folder, one needs to add a double quote before the file type.
For example, here is the code that I had used for my trial runs
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = “D:\Attachments”
For Each objAtt In itm.Attachments
If InStr(objAtt.DisplayName, “.pdf”) Then
objAtt.SaveAsFile saveFolder & “\” & objAtt.DisplayName
In the scenario above, the user only wanted PDF files to be saved to a folder in his D drive. The part of the code where I have highlighted as red should have the file extension (file type) within double quotes. In the link provided above this has been given within single quotes.
Although it is mentioned that this works for Outlook 2007 and Outlook 2010, I had tried on Outlook 2013 and it works beautifully without any hiccups. Give it a try! It’s awesome to see it working!