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
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
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
- Open the VBA IDE in Outlook. Alt-F11 will do this.
- 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.
- Now, paste the text below in the main VBA window.
- Close the VBA IDE.
- Create a Rule that calls the script. Tools -> Rules and Alerts -> New Rule...
- In the first screen of the new rule wizard, choose "Check messages when they arrive".
- 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.
- 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.
- 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
Post a Comment