Otlook vba and rule to forward email message and change subject

泄露秘密 提交于 2020-01-03 02:43:39

问题


I have a rule with script and almost works fine.. I would like to forward some specific incoming emails to an email address with rule but I also would like to change the subject a bit as well.

I have this code which works fine:

Sub ForwardEmail(Item As Outlook.MailItem)
    Set myForward = Item.Forward
    myForward.Subject = ("ITS - ") & Item.Subject
    myForward.Recipients.Add "backup@email.com"
    myForward.Send
End Sub

My problem is when this rule activated the forwarded emails will get my signature and also the "from: Sent: To: Subject:" lines from the previous email. Is there any way to remove them before forwarding the message?

Maybe if I send as a new email based on the incoming one can that work? My email includes a picture in the body (not attachment) so that can cause problem in my case.


回答1:


You may want to try this:

Sub ForwardEmail(Item As Outlook.MailItem)
    With Item.Forward
        .Subject = ("ITS - ") & Item.Subject
        .Recipients.Add "backup@email.com"
        ' You need to overwrite the Body or HTMLBody to get rid of the auto signature
        .HTMLBody = Item.HTMLBody ' <-- Or use .Body for Plain Text
        '.Display ' <-- For Debug
        .Send ' <-- Put break here to Debug
    End With
End Sub


来源:https://stackoverflow.com/questions/37483093/otlook-vba-and-rule-to-forward-email-message-and-change-subject

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!