Home > front end >  Empty HTML Body while creating Outlook meeting invite using VBA
Empty HTML Body while creating Outlook meeting invite using VBA

Time:11-19

I'm trying to create outlook meeting invite using VBA. Meeting invite is getting created. Subject and other fields are also getting updated correctly. But i'm getting empty body whenever i use .HTMLBody.

Tried copying other simple codes but none of them working. Not sure if i'm missing something here.

Below is the code that 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

CodePudding user response:

There is no HTMLBody for appointment items.

See https://social.msdn.microsoft.com/Forums/en-US/1e7cc383-bd2f-4d18-8cd1-9489bb3011ea/getset-appointment-body-type-fromto-rtfhtml-plain-text?forum=outlookdev

CodePudding user response:

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

.Body = "Hi"

This worked for me

  • Related