Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB Script to download outlook mail attachments

Posted on 2016-09-29
2
Medium Priority
?
52 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 14

Accepted Solution

by:
Alexei Kuznetsov (Outlook MVP) earned 2000 total points (awarded by participants)
ID: 41822219
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 14

Expert Comment

by:Alexei Kuznetsov (Outlook MVP)
ID: 41847977
The answer is given.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

610 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