I would like to insert text with format (links, bold, highlighted...) in an Outlook invite using Excel VBA.
I have a program that send invites from Excel. The body c
Try this:
Sub SetApptWithHTMLContent()
Dim olapp As Outlook.Application, appt As Outlook.AppointmentItem
Dim m As Outlook.MailItem
Dim rtf() As Byte
Set olapp = New Outlook.Application
Set m = olapp.CreateItem(olMailItem)
Set appt = olapp.CreateItem(olAppointmentItem)
appt.Subject = "Meeting request"
'...set other appointment properties
appt.Display
'put the HTML into the mail item, then copy and paste to appt
m.BodyFormat = olFormatHTML
m.HTMLBody = Range("A1").Value 'sample HTML stored in a cell
m.GetInspector().WordEditor.Range.FormattedText.Copy
appt.GetInspector().WordEditor.Range.FormattedText.Paste
m.Close False 'don't save...
End Sub
Sample HTML:
<h1>Title Here</H1>
<span style='background-color: #ffff00'>Table of stuff:</span><br>
<table>
<tr>
<td style='background-color: #ff9900'>One</td>
<td>Two</td>
</tr>
<tr>
<td>Three</td>
<td>Four</td>
</tr>
</table>
Final appointment body: