Change VBA script to send HTML email instead of text

Status
Not open for further replies.

StarEagle

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
I have used a VBA macro for years to forward emails to a fixed email address that was my task manager web based software. It worked but it forwarded a text email whether the original email was text or HTML. This was ok because that task manager did not like HTML emails. I have switched to a different task manager that does accept HTML emails which is great except my macro only forwards text emails.

I need help in modifying my macro to send emails as they are, text or HTML. I have tried some HTML VBA commands, but all I did was create a mess. Any assistance would be appreciated including hints as to what to try, including commands. The current macro is:

Sub TDFwd2()
Dim helpdeskaddress As String
Dim objMail As Outlook.MailItem
Dim strbody As String
Dim oldmsg As String
Dim emailSubject As String
Dim senderaddress As String
Dim emailTo As String
Dim addresstype As Integer
' Set this variable as your helpdesk e-mail address
helpdeskaddress = "dummy@fake.com"
Set objItem = GetCurrentItem()
Set objMail = objItem.Forward
' Sender E=mail Address
senderaddress = objItem.SenderEmailAddress
'Searches for @ in the email address to determine if it is an exchange user
addresstype = InStr(senderaddress, "@")
' If the address is an Exchange DN use the Senders Name
If addresstype = 0 Then
senderaddress = objItem.SenderName
End If
emailTo = objItem.To
emailSubject = objItem.subject
'adds the senders e-mail address as the created by object for the ticket and appends the message body
strbody = "Sent by: " & senderaddress & vbNewLine & "To: " & emailTo & vbNewLine & "Subject: " & emailSubject & vbNewLine & vbNewLine & objItem.Body
objMail.To = helpdeskaddress
objMail.subject = objItem.subject
objMail.Body = strbody
' remove the comment from below to display the message before sending
'objMail.Display
'Automatically Send the ticket
objMail.Send
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
 

StarEagle

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
I figured it out with a bit of experimentation.
 

JARROD

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Office 365 Exchange
Decent, need to accomplish something like this with mine.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
B Change Font and Font size using VBA Outlook VBA and Custom Forms 9
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
S Example VBA Macro - To Conditionally Change the From Account and Add a BCC Address on Emails Outlook VBA and Custom Forms 11
M VBA to change flag status in outlook contact item Outlook VBA and Custom Forms 3
H Change Default Email Account Using VBA Outlook VBA and Custom Forms 5
O VBA to Run Font Change on Outlook Startup Outlook VBA and Custom Forms 4
D Change sender name outlook vba 2010 Custom Userform Outlook VBA and Custom Forms 1
O VBA to change message format and add formatted signature Outlook VBA and Custom Forms 1
F VBA Code to change subject Like Outlook VBA and Custom Forms 3
K Outlook 2013 - Use VBA to change Due date of Tasks Using Outlook 3
K How to change status of a mail marked as a task (VBA) Outlook VBA and Custom Forms 2
S Change "This Week" flag start date behavior Using Outlook 1
D Change Microsoft Account password - what to do to update on all devices Using Outlook 4
S Outlook 2016 Change how Outlook shows me contacts in emails Using Outlook 0
witzker HowTo Change message Class of contact form Outlook VBA and Custom Forms 0
Z Outlook 365 delete reminder you can’t make change to contents of this-read only folder Using Outlook 4
witzker Pls help to change the code for inserting date in Ol contact body Outlook VBA and Custom Forms 5
R How to Change Margins In Google Docs...? Using Outlook 0
e_a_g_l_e_p_i Outlook 2010 How can I change the font size on right side appointment pane Using Outlook 12
D Change senders title Using Outlook 1
W Recurrence: delete older occurrences / change earliest start time Outlook VBA and Custom Forms 0
E Change sending account depending on Subjectline Outlook VBA and Custom Forms 0
J Outlook 2013 Change color of text in data fields of contacts in Outlook 2013? Using Outlook 10
B Change row background color of selected item Using Outlook 1
B Change from Address Outlook VBA and Custom Forms 0
X If you change expiration date of repeated task it dupplicates Using Outlook 1
E How to display "Change Folder" in Change Default Email Delivery Location in Exchange Outlook 2016 Using Outlook 1
B See "Change View" Drop Down as a List? Using Outlook 1
V Change start time based on message duration Outlook VBA and Custom Forms 2
R Folder pane width change Using Outlook 69
S Outlook 2010 unable to change default font Using Outlook 7
P How can I change my calendar view back Using Outlook 3
T Change the selected Message in the Outlook window Outlook VBA and Custom Forms 2
geofferyh How to change the Attachment File Name? Outlook VBA and Custom Forms 1
W Appointment occurrences change the location property Using Outlook 0
T Scheduled footer change Using Outlook 2
B Change font of reminder of an email header Outlook VBA and Custom Forms 3
CWM030 Name Change? Exchange Server Administration 9
V not able to change name in customize Ribbon Outlook VBA and Custom Forms 1
JoeG Appointment Delete/Change Recurrence Outlook VBA and Custom Forms 0
C Change Subject Line in Selected Emails Outlook VBA and Custom Forms 1
V Change default default save location to Quick Access Using Outlook 1
C Change default "Save Sent Item To" folder Outlook VBA and Custom Forms 9
B Do not change the From address in Outlook Templates Using Outlook 0
M Sudden change in From field - now very short Using Outlook 4
M cannot change delivery folders with IMAP accounts Using Outlook 0
S Email Format With Embedded Images and Tables Change Using Outlook 2

Similar threads

Top