1
我正在寫一個宏,允許我通過附件轉發當前郵件(通過功能區上的按鈕運行宏),然後刪除原始郵件。Outlook VBA發送後刪除郵件
但是,當我運行宏消息不會被刪除,我收到一封來自「系統管理員」的電子郵件,消息是un-deliverable
。
如果我註釋掉該行.DeleteAfterSubmit = True
該消息已發送但未刪除。
Dim objAttachment As Attachment
Dim strAttachment As String
Set objItem = GetCurrentItem()
Set objMsg = Application.CreateItem(olMailItem)
strAttachment = ""
For Each objAttachment In objItem.Attachments
strAttachment = strAttachment & " " & objAttachment.DisplayName ' FileName
Next
With objMsg
.Attachments.Add objItem, olEmbeddeditem
.Subject = objItem.Subject & " " & objItem.To
.To = "[email protected]"
.Body = "From: " & objItem.Sender & vbNewLine & _
"Sent: " & objItem.ReceivedTime & vbNewLine & _
"To: " & objItem.To & vbNewLine & _
"CC: " & objItem.CC & vbNewLine & _
"Subject: " & objItem.Subject & vbNewLine & _
"Attachment: " & strAttachment & vbNewLine & vbNewLine & _
objItem.Body
.DeleteAfterSubmit = True
.Send
End With
我認爲這只是防止在_Sent Items_ – jsotola
objMsg.Delete或objItem.Delete這取決於你想刪除哪一個省 – Sorceri