问题
I am currently working on a project, and I am having some trouble saving email attachments locally.
I currently have an outlook rule set up that directs all relevant emails to an Outlook folder. I want to programatically pull all of those email attachments, and save them all into one folder on my local machine.
How do I go about pulling the attachments into a specified location? Thanks!
回答1:
Please try the code below:
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "c:\temp"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub
For more information, please see automatically Save outlook attachment
来源:https://stackoverflow.com/questions/51830119/saving-outlook-attachment-locally-via-vba