Parsu
Parsu

Reputation: 83

Empty HTML Body while creating Outlook meeting invite using VBA

I'm trying to create an Outlook meeting invite.

The meeting invite is created. Subject and other fields are also updated.

I get an empty body when I use .HTMLBody.

Code I tried:

Set OutApp = Outlook.Application
Set OutMeet = OutApp.CreateItem(olAppointmentItem)

With OutMeet
    .Subject = Subj
    .RequiredAttendees = ActiveSheet.Range("G9").Value
    ThisWorkbook.Sheets("Sheet1").Select
    .Start = ThisWorkbook.Worksheets("Sheet1").Range("D2").Value
    .Duration = 10
    .Importance = olImportanceHigh
    .ReminderMinutesBeforeStart = 15
    ThisWorkbook.Sheets("Sheet2").Select
    .BodyFormat = olFormatHTML
    .HTMLBody = "<html><head></head><body>Hi</body></html>"
    Application.Visible = True
    MeetingStatus = olMeeting
    .Location = "Microsoft Teams"
    .Display
End With
Set OutMeet = Nothing
Set OutApp = Nothing
End Sub

Upvotes: 0

Views: 1204

Answers (3)

Masterofrpm
Masterofrpm

Reputation: 1

There is a work around for this detailed by AjimOthy that works like a charm. I initially hit this thread, but found this solution when I was trying to figure out how to easily switch over to RTF format.

https://stackoverflow.com/a/24249250/17749494

Essentially you create two Outlook items, use Word editor to copy the formatted message from an email that DOES allow .HTMLBody to the appointment/meeting that does NOT allow .HTMLBody.

Only segment I had to add was

objMyMsgItem.Delete

At the end of my Sub to close the Mail object that remains open.

Upvotes: 0

Brett
Brett

Reputation: 351

Make sure you have your outlook reference libraries turned on and then try

.Body = "Hi"

This worked for me

Upvotes: 0

Related Questions