VB Script to download outlook mail attachments
Posted on 2016-09-29
I am using a VB Script on Outlook that downloads any attachment in an outlook mail to a specific folder.
Then i am calling this script in an Outlook Rule where i define to which mail this script has to work for.
The issue that i am facing is that the script works from new-old fashion providing me oldest attachment and not newest attachment.This is for the attachments with same name in every mail.
What shall i add to the below script so that it moves in old - new sort downloading new attachments to override old attachments with the same name.
VB Script used:
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "E:\Projects\Takeda\Data\Zipped Incremental data\incremental\"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
Set objAtt = Nothing