Outlook将收到邮件的附件保存在磁盘

1. 新建一个宏

1)文件->选项->自定义功能区, 把主选项卡的 开发工具勾选上。

2)开发工具->宏,输入宏名,创建。

加入以下代码

Public Sub SaveAttach(Item As Outlook.MailItem)
SaveAttachment Item, "D:", "*.docx"
End Sub

' 保存附件
' path为保存路径,condition为附件名匹配条件
Private Sub SaveAttachment(ByVal Item As Object, path$, Optional condition$ = "*")
Dim olAtt As Attachment
Dim i As Integer

If Item.Attachments.Count > 0 Then
For i = 1 To Item.Attachments.Count
Set olAtt = Item.Attachments(i)
' save the attachment
If olAtt.FileName Like condition Then
olAtt.SaveAsFile path & olAtt.FileName
End If
Next
End If
Set olAtt = Nothing
End Sub

3)点击 宏安全性->宏设置->启用所有宏,电子邮件安全性->勾选文件夹中的脚步下的两个选项

2. 创建一个主题包含某些内容的规则,然后执行SaveAttach脚本。

最后重启outlook。

参考:http://zhiqiang.org/blog/it/auto-save-attachment-in-outlook.html

原文地址:https://www.cnblogs.com/szhx/p/4298758.html