我正在编写一个宏,允许我转发当前消息(通过功能区上的按钮运行宏)作为附件,然后删除原始消息。
但是,当我运行宏时,邮件不会被删除,我收到来自“系统管理员”的邮件,邮件是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@outlook.com"
.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
答案 0 :(得分:0)
在 objItem.Delete
With...End With
With objMsg
.Attachments.Add objItem, olEmbeddeditem
.subject = objItem.subject & " " & objItem.To
.To = "email@outlook.com"
.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
.Send
End With
objItem.Delete