Retain Original Message When Forwarding With Macro

Status
Not open for further replies.

Randy Schmidt

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
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
 
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
 
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
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
R How can I retain embedded object with voting button reply? Using Outlook 5
T Exchange / Outlook 2010 - How to cancel meetings but retain the calendar entry Using Outlook 4
D How to retain attachments in message when replying to sender Using Outlook 4
D Script help - retain forwarded email body & location of script Outlook VBA and Custom Forms 5
D Outlook VBA forward the selected email to the original sender’s email ID (including the email used in TO, CC Field) from the email chain Outlook VBA and Custom Forms 2
J Quick steps delete original email and move reply/sent email to folder Using Outlook 2
F Forward incoming email with 4 embedded images in the body without original sender Outlook VBA and Custom Forms 22
T Macro to move reply and original message to folder Outlook VBA and Custom Forms 6
S Email Generated from another program and then edited sends original email. Using Outlook 2
T Original email text not shown when replying or forwarding the email. Using Outlook 9
Bering Forward selected email without the original email appended Outlook VBA and Custom Forms 0
B disappearing original when attach to email Using Outlook 1
L Macro/VBA to Reply All, with the original attachments Outlook VBA and Custom Forms 2
B Outlook 2013 erratically deleting original file that is attached Using Outlook 0
Z VBA to convert email to task, insert text of email in task notes, and attach copy of original email Outlook VBA and Custom Forms 4
D Keep Original html body when forwarding an email Outlook VBA and Custom Forms 7
J Auto Forward - Include Attachment and change Subject depending on original sender Outlook VBA and Custom Forms 3
F Move mails from Deleted Items folder back to its original folder where the mails got deleted Using Outlook 0
Diane Poremsky Foward a Message and CC the Original Recipients Using Outlook 0
H send reminder if no reply received on first or original email using macro Using Outlook 2
H Keep Original email unread after autoreply Outlook VBA and Custom Forms 2
oliv- Why custom form is different from original ipm.contact ? Outlook VBA and Custom Forms 4
S Reply & Forward Date in original message incorrect Using Outlook 2
E Button in body of email to approve/reject with original text Using Outlook 1
S Need CC: to show the original To: recip[ients Using Outlook 4
R Forwarding and keeping Original intact Using Outlook 3
B Auto reply using macro include original email Using Outlook 4
J Image in original e-mail is hyperlinked when a reply with the image is hyerplinked Exchange Server Administration 1
J Adding original email text to outlook message template Outlook VBA and Custom Forms 2
L Creating a Task from Email and Attaching Original Email Outlook VBA and Custom Forms 6
L Auto Forward without presenting the original sender Outlook VBA and Custom Forms 1
J How to redesign the Contact form without losing the original layout? Using Outlook 2
A automatically remove flag from original message when a response was received Using Outlook 2
C Remove iCloud so I can have original outlook calendar and contacts Using Outlook 43
C Hover display of DL shows original owner, not current Using Outlook 2
S Outlook 2k/2k3 Reply or Forward: Signature image replaced by original sender Using Outlook 3
M 2010: sorting by ORIGINAL send date Using Outlook 1
C Create a rule to only check new content in email - disregard original content Using Outlook 3
A Creating a rule that both forwards the original attachment and uses a template Using Outlook 11
R Recall Email Message when i'm not the original sender - Outlook 2010 Using Outlook 2
C Outlook/Exchange 2010 Recover Deleted Items to original folder Using Outlook 2
P Reply to original sender, not to forwarder ? Outlook VBA and Custom Forms 1
S -> [O2007]: get the message HTML original source code? Outlook VBA and Custom Forms 6
R Auto Reply with Original Email and any attachments Outlook VBA and Custom Forms 1
S Original Attachment not removed Outlook VBA and Custom Forms 4
R keep track of the original sender Outlook VBA and Custom Forms 3
M Search message, then (1) Jump to folder & (2) Select message that you searched for Outlook VBA and Custom Forms 2
Kika Melo How to mark as Junk any message not from Contacts (in Outlook.com) Using Outlook 3
G Outlook 365 My iCloud Outlook doesn’t work after reinstalling Microsoft365 on Windows 10 PC – now I get error message on contacts and calendar Using Outlook 1
G Get current open draft message body from VBA Outlook VBA and Custom Forms 1

Similar threads

Back
Top