码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-02-24 17:27:53      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:

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

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

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!