Home > Enterprise >  Automatically forward email by VBA outlook
Automatically forward email by VBA outlook

Time:11-18

I am using below command to automatically forward email. I added outlook rule already.

I'm having trouble with automatically forward email.

Please help me with a few questions below

  1. Outgoing email address

Currently: can only send 1 email

Desire: send to many different emails

  1. Email content

Currently: no email content yet

Desired: add a command about email content including ( title mail any content )

Thanks for helping me.

Sub AutoForwardAllSentItems(Item As Outlook.MailItem)
Dim strMsg As String
Dim myFwd As Outlook.MailItem

Set myFwd = Item.Forward

myFwd.Recipients.Add "[email protected]; [email protected]; [email protected]"
xStr = "<p>" & "Hi, Your email has been received. Thank you!" & "</p>"
myFwd.HTMLBody = xStr & .HTMLBody

myFwd.Send
Set myFwd = Nothing
End Sub

CodePudding user response:

You are not specifying where you are getting .HTMLBody from, but I assume it to be from the Item argument.

You can add that in like this:

myFwd.Recipients.Add "[email protected]"
myFwd.Recipients.Add "[email protected]"
myFwd.Recipients.Add "[email protected]"

xStr = "<p>Hi, Your email has been received. Thank you!</p>"
myFwd.HTMLBody = xStr & Item.HTMLBody
  • Related