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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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
 

Randy Schmidt

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
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.
Thread starter Similar threads 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
A Would like to transfer my outlook 2003 contacta and address book to windows live and retain them in outlook as well Using Outlook 2
S OL2007/XP views will not retain settings. Really need some help here. Using Outlook 2
S Sorting out sent messages. How can I consolidate 3 sent message directories and successfully retain sent messages across 3 differnt computers using th Using Outlook 2
D my NK2 file will not up date. the last update was in August 2010. The program will not retain any Using Outlook 1
S How to retain "Date Sent" and "Date Received" data when copying email messages from Outlook to an Ex Using Outlook 2
C How can I retain all old appointments on my Blackberry and in Outlook when syncing? Using Outlook 2
D Autocomplete doesn't retain the database after Outlook 2010 is restarted. Using Outlook 1
N how to retain folder tree view after outlook closed? Using Outlook 1
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
B 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 New Slipstick.com Articles 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
K Sending to Original Sender Exchange Server Administration 3
S Save an attachment back to the original e-mail. Using Outlook 2
L Exchange 2010 modifies the original message Exchange Server Administration 4
C Configuring automatic reply with an approved message attached to original received message that will be forward to a 3rd party Using Outlook 2
P Delivery receipt with original message attached? Exchange Server Administration 2
R Outlook 2007 - Reply with / without original message text Using Outlook 1
G Prevent Changes in text of Original e-mail Using Outlook 1
A Forward original messages with NDR to postmaster? Exchange Server Administration 2
P Want to keep original .pst file as main email file after upgrading to Outlook 2010 Using Outlook 1
M Eliminate trail verson of MSOutlook and go back to my original Outlook Express. Using Outlook 2
J Outlook doesn't save forwarded message if original is located in an archive PST Using Outlook 2
Similar threads


















































Top