Hi all,
Hoping this is a simple fix.
I have the below script that I found on another forum that runs as a rule in Outlook to save .pdf email attachments with a timestamp that come from my printer. That part all works fine.
The problem I'm having is that it will save the file with the .pdf as part of the file name.
For example, if the attachment is called test.pdf then my code will run and save it as a .pdf to my documents as "test.pdf (timestamp)".
I think it could be a case of just needing some additional code to get only the attachment's name and not the file extension.
If it helps with a solution, it is always .pdf file types that I run this code for.
Hoping this is a simple fix.
I have the below script that I found on another forum that runs as a rule in Outlook to save .pdf email attachments with a timestamp that come from my printer. That part all works fine.
The problem I'm having is that it will save the file with the .pdf as part of the file name.
For example, if the attachment is called test.pdf then my code will run and save it as a .pdf to my documents as "test.pdf (timestamp)".
I think it could be a case of just needing some additional code to get only the attachment's name and not the file extension.
If it helps with a solution, it is always .pdf file types that I run this code for.
VBA Code:
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:\Users\Jfin1ty\Documents\"
Dim dateFormat
dateFormat = Format(Now, "dd-mm-yyyy hh-mm-ss")
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & objAtt.DisplayName & " " & dateFormat & ".pdf"
Set objAtt = Nothing
Next
End Sub