Saving outlook attachment locally via VBA

时光总嘲笑我的痴心妄想 提交于 2020-06-29 04:18:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!