Need VBA Outlook help- saves over duplicate file
Trying to auto save incoming attachments based on a rule and then running VBA to save the file to a folder. The code works but I ran into a problem when there are duplicate files named with the same name, it will just overwrite the old file. Is there a way to add to the following code a number to end of the naming convention? like 1 , 2, 3 and so on so that it will not overwrite the other file? or better yet add the date to the end of the file path when saving? Thanks for your help
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Const saveFolder As String = "C:\Users\wrighta\Documents\Test"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "" & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub