The following code (I pulled from several sources) now works, when I receive an email with special words in the subject line, it runs a script that runs below.
In this code, the subject line is saved, the text of the message body and the forward is added to the intended recipient.
However, if the email I receive has an attachment, the code no longer sends anything. I need to forward the attachment that was sent to me by email (only using the code to add text to the body of the email, otherwise I would just set a rule).
CODE BELOW:
Sub ForwardEmail(item As Outlook.MailItem) Dim oExplorer As Outlook.Explorer Dim oMail As MailItem Set oExplorer = Application.ActiveExplorer On Error GoTo Release If oExplorer.Selection.item(1).Class = olMail Then Set oMail = item.Forward oMail.Subject = oMail.Subject oMail.HTMLBody = "Have a nice day." & vbCrLf & oMail.HTMLBody oMail.Recipients.Add "email address here" oMail.Save oMail.Send End If Release: Set oMail = Nothing Set oExplorer = Nothing End Sub
source share