Solved

VB Script to download outlook mail attachments

Posted on 2016-09-29
2
10 Views
Last Modified: 2016-10-18
Hi All,
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      
Next
End Sub
0
Comment
Question by:Pulkit Thukral
  • 2
2 Comments
 
LVL 13

Accepted Solution

by:
Alexei Kuznetsov earned 500 total points (awarded by participants)
Comment Utility
Your script effectively overwrites the existing file. How do you run your rules? Manually or just automatically for incoming emails? If manually, the order of emails is not guaranteed at all.

In order to process emails in a particular order (by date, for instance) you need to create a much more complex script that will get emails in a sorted order, check all required conditions and save attachments.

Alternatively, you can add the current date (and maybe part of the time) to the name of your saveFolder.
0
 
LVL 13

Expert Comment

by:Alexei Kuznetsov
Comment Utility
The answer is given.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Outlook Free & Paid Tools
If you don't know how to downgrade, my instructions below should be helpful.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now