我正在尝试创建一个宏来从我收到的电子邮件中下载附件,然后删除该电子邮件。
我有宏下载附件,但是,我不知道如何删除它下载后的电子邮件。当我使用规则时,它会在下载附件之前删除电子邮件。
这就是我所拥有的:
Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = "S:\Training and Curriculum\Staff Training Files\01 scans\"
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Next
End Sub
答案 0 :(得分:1)
从我在那个sub上可以看出,你传递MItem作为Outlook.MailItem对象,如果我正确地读出你的问题,那就是你要删除的项目。在循环中next
之后,您应该能够执行MItem.Delete,它将在保存文件后删除该特定项目。
Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = "S:\Training and Curriculum\Staff Training Files\01 scans\"
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Next
MItem.Delete 'This is the delete command
End Sub
以下是MailItem.Delete
- MSDN MailItem Delete Method