I would like to ask for help. I am using Office 365 and tried to use this code to save attachments from Outlook and rename them as subject of email. However I encountered the problem.
This VBA code is working:
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:\Users\ppp\Desktop\Image Test"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "" & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub
However when I want to amend it so that it saves the pdf attachments with the subject of the email it is not working. File is being saved down as type: file (not PDF) and size is 0 KB. Additionaly it doesn't save down the file with the subject name but with the name of the attachment.
VBA code which I am using
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:\Users\ppp\Desktop\Image Test"
MSN = Trim(itm.Subject)
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "" & itm.Subject & ".PDF"
Set objAtt = Nothing
Next
End Sub
Can somebody advise me please?