Quote Originally Posted by inxain
Hi

I use the following variation of the same script in Outlook 2003 to insert the date and time stamp before the file extension (not very elegant but it works)

Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "c:\a"

For Each objAtt In itm.Attachments
posr = InStrRev(objAtt.FileName, ".")
ext = Right(objAtt.FileName, Len(objAtt.FileName) - posr)
posl = InStr(objAtt.FileName, ".")
fname = Left(objAtt.FileName, posr - 1)
objAtt.SaveAsFile saveFolder & "\" & fname & "_" & Format(itm.ReceivedTime, "ddmmyyyy_hhmm") & "." & ext
Set objAtt = Nothing
Next
End Sub
This script works but for us it’s more work. The clients send us a huge amount of emails per day. All these attachments have long file names. Adding the date and time to every file gives them more work since when the attachment is translated it need to be returned to the client with the original file name. With this script, the user needs to delete the added date and time. All this is additional work.

What I need is to rename an attachment only if a file with the same name already exists in the folder. Let say I have a file “autosave.doc” in my C:\attachment\ folder and I receive a new email with a file named autosave.doc. I would like the script to check if a file with that name already exists, if so, rename it autosave1.doc.

I’m sure that this is possible but I’m not a programmer and have no clue on how configure it.

TY
Mike