PDA

View Full Version : Save attachments and rename if file exist



ekto
04-23-2013, 01:39 AM
Hi,

We have five outlooks running on the network and the objective would be to save attachments to a network share. This is how our old Eudora just to work. The reason is that this way, I can just shout to my collegue and ask him to look at certain file in the network share.

I found next code:

Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "E:\temp\"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub


What I would like it to do is to rename the file if there is a file with that name.

Example:
File named list.txt is recieved by me and my collegue.
the file that is recieved later, get's saved as list1.txt

Is this possible and if so, how?

ekto
04-24-2013, 04:18 AM
Any ideas what should I be looking?

skatonni
04-26-2013, 07:46 PM
Some ideas here http://vbaexpress.com/forum/showthread.php?t=32499