Using VBA to automatically save attachment to network folder - OVERWRITE HELP!!
Hello everyone
I use the following VBA to automatically save all attachments in outlook to our network folder
Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = "\\Dck-server-02\g\00 Uploads\"
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Next
End Sub
I then create a rule within outlook to have all messages with attachments from a specific sender to run the above VBA
My issue is, the attachments that i will be receiving are 100% likely to have the same filename and i have noticed on test runs that the most recent attachment will overwrite the previous one when saved into the directed network folder.
Is there an edit to the VBA that anyone can suggest that will append a number or something similar to the end of the attachment filename??
For example,
If the filename was 'site inspection' would it be possible to edit the VBA to save the attachments as 'site inspection-1' 'site inspection-2' 'site inspection-3' etc...
Please, if anyone is able to help with this issue it would be greatly appreciated!!