save attachments macro - multiple attachments with the same file name
Am Wed, 3 Jun 2009 04:25:37 -0700 (PDT) schrieb RC:
The following code works great, except some emails have multiple
attachments which have the same file name. For example, you take some
pictures with you digital camera and the camera names them,
image01.jpg, image02.jpg, you save the pictures in a folder on your
computer, erase the memory stick in the camera, take some more
pictures, again the camera names them, image01.jpg, image02.jpg,
etc., you save them in a different folder on your computer and then
attach all the photos to an email.
"Michael Bauer [MVP - Outlook]" wrote:
You could use the Dir function and see whether a given filename already
exists; if so, add a number and search again for an existing file with the
same name; loop until you have found a 'free' file name.
or you can use the following code:
For i = 1 To myAttachments.Count
myFID = myOrt & myAttachments.Item(i).DisplayName
While myFS.FileExists(myFID)
strPrompt = myFID
myFID = InputBox("File already exists. Please enter new file name.", _
"SaveAttachment", strPrompt)
Wend
myAttachments.Item(i).SaveAsFile myFID
...
--
Wilfried Hennings
please reply in the newsgroup, the e-mail address is invalid
|