简体   繁体   中英

Otlook vba and rule to forward email message and change subject

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM