Yogibear88
New Member
- Joined
- Sep 28, 2017
- Messages
- 6
Hi all,
I have a code that appends the timestamp to the file attachment. Currently the timestamp is placed before the filename but when I tried to modify the code to insert timestamp after the filename, it changes the file extension and the file attachment becomes unreadable. I know that there is this code using InStrRev (Fname, ".") but I am not too familiar with the coding syntax and could not get it to work.
Appreciate if someone can help.
I have a code that appends the timestamp to the file attachment. Currently the timestamp is placed before the filename but when I tried to modify the code to insert timestamp after the filename, it changes the file extension and the file attachment becomes unreadable. I know that there is this code using InStrRev (Fname, ".") but I am not too familiar with the coding syntax and could not get it to work.
Appreciate if someone can help.
VBA Code:
Public Sub saveAttachToDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim dateFormat As String
saveFolder = "D:\Users\bob\TEMP\Daily Report"
dateFormat = Format(Now, "yyyy-mm-dd")
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & dateFormat & "_" & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub