Search code examples
excelvbaoutlookicalendar

Adding atendees to a .ics file that is sent as an attachment


I am trying to create a meeting invite (with attendees), and then attach that invite to another email I generate (for someone else to send that meeting invite). In my research, it appears I need to create the Meeting Invite, save it as a file, and then attach the file to the outgoing email.

These are my attempts so far:

  • I couldn't have Outlook.MeetingItem to work, I read it needs to be an Outlook.AppointmentItem
  • with Outlook.AppointmentItem, code creates an appointment rather than an invite. In my attempts/research, I saw that you need attendees for the Appointment to be saved as a Meeting Invite, but I couldn't get my attendees to "stick", so it comes up as an Appointment once we open it
    • I tried adding a string with the email addresses

    • I tried looping a collection and doing a ".Recipient.Add" individually

  • saving the Meeting as a ".ics" file (instead of ".msg"). This works (as in, the attachment comes up as a Meeting rather than an Appointment), but it also doesn't save the Attendees

After either approach below, I do:

olMeeting.SaveAs desiredFileName, olICal

I attach the file to the outgoing email and send it.

Upon opening the email, everything is there except for the Attendees.

Thanks in advance

Attempt #1 using a string for the attendees

With olMeeting
    .requiredAttendees = requiredAttendeesString
    .Recipients.ResolveAll
    .subject = subject
    .BodyFormat = olFormatHTML
    .body = body
    .Start = meetingStartTime
    .End = meetingEndtime
    .location = location
    .ReminderMinutesBeforeStart = 15
End With

Attmept #2 doing a .recipients.Add from a requiredAttendeesCollection

With olMeeting
    For Each currentAttendee In requiredAttendeesCollection
        .Recipients.Add CStr(currentAttendee)    
        .Recipients.item(.Recipients.Count).Type = olRequired
    Next
    .Recipients.ResolveAll
    .subject = subject
    .BodyFormat = olFormatHTML
    .body = body
    .Start = meetingStartTime
    .End = meetingEndtime
    .location = location
    .ReminderMinutesBeforeStart = 15
End With

Solution

  • Try to create a meeting invitation in Outlook and send it to a Gmail mailbox - you can then look at the raw MIME meeting invitation source in your Google mailbox. You can then create a similar ICS file explicitly in your code - it is just a text file.