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