• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Retain Original Message When Forwarding With Macro

Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
#1
I am new to Outlook VBA and cannot figure out how to forward a message with added text, keeping the original message intact. Here is the code I'm trying (and I really don't understand a lot of it):

Sub Forward_Invoice_To_Joseph()
Dim objMail As Outlook.MailItem
Dim strHTML As String
Dim Msg As Object
Set Msg = HTMLBody
strHTML = "Hi Joseph,<p><p>Please advise if this invoice meets your approval<p><p>Thanks,<br>Randy"
Set objItem = GetCurrentItem()
Set objMail = objItem.Forward
Set objApp = CreateObject("Outlook.Application")
Set objSelection = objApp.ActiveExplorer.Selection
objMail.To = "xxx@xxx.edu"
objMail.CC = "xxx@xxx.edu"
With objMail
.BodyFormat = olFormatHTML
.HTMLBody = strHTML & Msg.HTMLBody
End With
objMail.Display
Set objItem = Nothing
Set objMail = Nothing
End Sub

Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
Case Else
End Select
End Function

I copied and pasted parts of this code from the resources I found (like this website). I am simply trying to preface a forwarded message with what's in strHTML. It took me a long time to figure this part out but it does work. However, the original message is gone when I execute the macro. Please help me understand what I'm doing wrong. Once I do, I have many very similar repetitive messages and forwards that I would replicate using this type of code.

Thank You,
RS
 
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#2
I'm not sure what this does -
Set Msg = HTMLBody

or this
Set objApp = CreateObject("Outlook.Application")
Set objSelection = objApp.ActiveExplorer.Selection

but this works -
Code:
Sub Forward_Invoice_To_Joseph()
Dim objMail As Outlook.MailItem
Dim strHTML As String

strHTML = "Hi Joseph,<p><p>Please advise if this invoice meets your approval<p><p>Thanks,<br>Randy"

Set objItem = GetCurrentItem()
Set objMail = objItem.Forward

With objMail
.To = "xxx@xxx.edu"
.CC = "xxx@xxx.edu"
.BodyFormat = olFormatHTML
.HTMLBody = strHTML & .HTMLBody
.Display
End With

Set objItem = Nothing
Set objMail = Nothing
End Sub
 
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
#3
I'm not sure what this does -
Set Msg = HTMLBody

or this
Set objApp = CreateObject("Outlook.Application")
Set objSelection = objApp.ActiveExplorer.Selection

but this works -
Code:
Sub Forward_Invoice_To_Joseph()
Dim objMail As Outlook.MailItem
Dim strHTML As String

strHTML = "Hi Joseph,<p><p>Please advise if this invoice meets your approval<p><p>Thanks,<br>Randy"

Set objItem = GetCurrentItem()
Set objMail = objItem.Forward

With objMail
.To = "xxx@xxx.edu"
.CC = "xxx@xxx.edu"
.BodyFormat = olFormatHTML
.HTMLBody = strHTML & .HTMLBody
.Display
End With

Set objItem = Nothing
Set objMail = Nothing
End Sub
Hi Diane,
I was experimenting with things that I have no concept of yet! Those commands were pure guesses. I am well-accustomed with writing code in Excel but I haven't yet gotten a feel for Outlook VBA. I'll use it quite a bit more once I gain the needed familiarity. Thanks for your help.
Randy
 

Similar threads