Tamas Kosa
Tamas Kosa

Reputation: 352

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.

Upvotes: 1

Views: 8713

Answers (1)

PatricK
PatricK

Reputation: 6433

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

Upvotes: 1

Related Questions