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 contains plain text. I am using .body but I am afraid I will have to use a different approach (.HTMLBody doesn't work for invites and RTFbody seems to be over complicated from what I have read).
I have body templates in Word, in Outlook as quick parts, in the clipboard and some other places.
Code:
Sub Invite_Merge(meeting_date As Date, meeting_time As Double,
meeting_duration As Integer, client_email As String, meeting_subject As String,
meeting_location As String, client_name As String, meeting_body As String,
meeting_sender As String)
Dim O As Outlook.Application
Set O = New Outlook.Application
Dim OAPT As Outlook.AppointmentItem
Set OAPT = O.CreateItem(olAppointmentItem)
OAPT.MeetingStatus = olMeeting
Dim meeting_start
meeting_start = DateValue(meeting_date) + meeting_time
With OAPT
.Recipients.Add (client_email)
.Subject = meeting_subject
.Start = meeting_start
.Duration = meeting_duration
.Location = meeting_location
'.body = here is where I have trouble, the property body only allows me to insert plaintext, .HTMLBody is not a AppointmentsItem property and I have not found an example code on how to use convert a formatted text (with links, bold, different fonts...) into a compatible .RTFBody byte array
.Display
'.Send
End With
End Sub
Sub Send_Invites()
row_number = 2
Do
DoEvents
row_number = row_number + 1
If IsEmpty(Sheet1.Range("D"& row_number)) = False Then
Call Invite_Merge(Sheet1.Range("A"& row_number), Sheet1.Range("B"& row_number), Sheet1.Range("C"& row_number), Sheet1.Range("D"& row_number), Sheet1.Range("E"& row_number), Sheet1.Range("F"& row_number), Sheet1.Range("G"& row_number), Sheet1.Range("H"& row_number), Sheet1.Range("A"& "1"))
End If
Loop Until row_number = 100
End Sub