vba - Outlook 脚本不会保存附件
问题描述
下面的 Outlook 规则应该将来自 sender@bookstore.com 的带有礼品卡购买主题行的附件保存到磁盘,然后将电子邮件移动到“删除项目”文件夹,这样它就不会再次处理它。该规则在收到新电子邮件并将电子邮件移至“删除项目”文件夹但未保存附件时运行。
我怀疑该规则首先将邮件移动到“删除项目”文件夹,然后执行脚本以保存不再位于“收件箱”文件夹中的电子邮件附件。
我无法更改以下 Outlook 规则的顺序以先执行脚本然后移动邮件,但 Outlook 不允许。
有什么推荐吗?
Apply this rule after the message arrives
from sender@bookstore.com
and with Gift Card Purchase in the subject
and on this computer only
move it to the Deleted Items folder
and run Project1.SaveAttachment
Public Sub SaveAttachment(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = "C:\Temp\"
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Next
End Sub
解决方案
在您的代码中使用MailItem.Delete 方法 (Outlook)
通过删除move it to the Deleted Items folder
然后将以下内容添加到您的代码来更新您MItem.Delete
的规则Next
例子
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Next
MItem.Delete
推荐阅读
- node.js - 如何使用节点为 mongodb 编写聚合查询
- python - Python:提取文本文件中两个字符串之间的值
- javascript - 将徽标放在导航栏上会影响导航栏上的整个文本
- ios - iPhone 11 上前置位置的默认 AVCaptureDevice 太“宽”
- android - Audio filnger 中的混音器线程是如何创建的,以及 app 和 audio flinger 混音器之间的映射是如何完成的?
- arrays - 线性代数可变自由度力向量的最佳和最有效格式?
- python - 如何将实例属性初始化为 numpy 数组?
- file - 使用 SharePlum for Sharepoint 下载文件
- linux - 如果匹配显示成功或失败,如何匹配文件中的语法
- javascript - 使用自动换行在 React 中渲染逗号分隔的链接