Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Every morning i receive an e-mail from a person, and it contains a spreadsheet attachment. I have managed to create an outlook rule that catch these e-mails. Now, is it possible to have the attachment from each of these automatically saved into a local folder, with the filename YYYY-MM-DD.xls?

The attachment in the mail has a randomly generated filename, so it needs to take the date of when the mail is sent to pick a filename. NB: this is on my laptop, so there's a chance that the e-mail is sent on a day other than the day it is received by me (such as when it's switched off for a day), so using "todays date" is not a viable option.

EDIT: using Windows 7 with Outlook 2013

share|improve this question
What version of Outlook and what OS? – CharlieRB Nov 12 '12 at 12:57
up vote 2 down vote accepted

To do what you want, you will need to mix a little VBA and Rules together. Not sure what version of Outlook you are using, so no guarantees here. This was tested on Outlook 2010.

This article will help you get things setup -Rule to automatically save attachment in Outlook .

The code below is modified specific to your saving the file with the name format of yyyy-mm-dd.

Public Sub SaveToDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim dateFormat

dateFormat = Format(Now, "yyyy-mm-dd")

'Change this path to the your folder location
saveFolder = "c:\temp\"

objAtt.SaveAsFile saveFolder & "\" & dateFormat & ".xls"

Set objAtt = Nothing

End Sub

Once you set up this rule to run this script, it will save any attachment from this person each time it receives one (and gives it a .xls extension). If you wish to change that, you will have to modify your rule or turn it off.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .