I am trying to address a list of clients by their name when I send them meeting invitations. Clients must not see other invitees. I have tried several approaches: add clients one-by-one as a Resource
, changing meeting notes text each time, forwarding the meeting as an iCalendar item, no luck.
Objective:
Change all attendees from
Required
toResource
(I can do this)
I have done a lot of research and could not find a way to forward a meeting that simulates the user interface version.
Background information:
- I have created a Zoom meetings appointment of which I know the location URL
- I can successfully access this appointment as an
Outlook.AppointmentItem
usingRestrict
- I cannot add the list of clients directly as
Resource
because then I cannot customize each invite - I cannot use
AppointmentItem.ForwardAsVcal
as that forwards the meeting as an attachment and does not occupy calendar space for the client (also I believe it looks unprofessional) - I have failed to use
MeetingItem.Forward
because my object is anOutlook.AppointmentItem
- I have successfully added new clients using
Recipients.Add
and.Type = olResource
- I have successfully modified meeting notes using
AppointmentItem.GetInspector().WordEditor.Range.FormattedText
but this causes previous invites to be canceled and updates text in the invitation so everyone sees the last invite
Code:
Accessing the item successfully
Private Function getMeeting() As Outlook.AppointmentItem
Dim settingsWS As Worksheet
Set settingsWS = ThisWorkbook.Sheets("Settings")
Dim meetingStart As Date, meetingEnd As Date
meetingStart = settingsWS.Cells(2, 1).Value 'start time
Dim locationString As String
locationString = settingsWS.Cells(2, 2).Value 'location url
Dim oCalendar As Outlook.Folder
Dim oItems As Outlook.Items
Dim strRestriction As String
daStart = Format(meetingStart, "mm/dd/yyyy hh:mm AMPM")
daEnd = DateAdd("h", 2, daStart)
daEnd = Format(daEnd, "mm/dd/yyyy hh:mm AMPM")
strRestriction = "[Start] >= '" & daStart & "' AND [End] <= '" & daEnd & "'"
strRestriction = strRestriction & " AND [Location] = '" & locationString & "'"
Set oCalendar = GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar)
Set oItems = oCalendar.Items.Restrict(strRestriction)
Set getMeeting = oItems(1)
End Function
My failed forwarding trials:
Private Sub sendInvites(oAppt As Outlook.AppointmentItem)
Dim oMail As Outlook.MailItem, oAtt As Outlook.Recipient, embeddedInvitation As OLEObject
Dim industryWS As Worksheet
Set industryWS = ThisWorkbook.ActiveSheet
Dim attendeeRange As Range
Set attendeeRange = industryWS.Cells(3, 1).CurrentRegion 'list of clients
Dim attendeeCompany As String, attendeeEmail As String
Dim attendeeName As String, attendeePrefix As String
Dim attendeeCount As Long, attendeeIndex As Long
attendeeCount = attendeeRange.Rows.Count - 1
For attendeeIndex = 1 To attendeeCount
attendeeCompany = attendeeRange.Cells(attendeeIndex + 1, 1).Value
attendeeEmail = attendeeRange.Cells(attendeeIndex + 1, 2).Value
attendeeName = attendeeRange.Cells(attendeeIndex + 1, 4).Value
attendeePrefix = attendeeRange.Cells(attendeeIndex + 1, 5).Value
Application.StatusBar = "Sending invites (" & CStr(attendeeIndex) & "/" & CStr(attendeeCount) & ") " & attendeeEmail
Set oMail = Outlook.Application.CreateItem(olMailItem)
'Set oMail = oAppt.ForwardAsVcal
oMail.To = attendeeEmail
oMail.BodyFormat = olFormatHTML
oMail.HTMLBody = getInvitationBody(attendeeName, attendeePrefix) & oMail.HTMLBody 'return invitation mailbody as HTML
'Dim fsd As MeetingItem
'fsd.Forward
'Set oAtt = oAppt.Recipients.Add(attendeeEmail)
'oAtt.Type = olResource
'oAppt.GetInspector().WordEditor.Range.FormattedText.Delete
'oMail.GetInspector().WordEditor.Range.FormattedText.Copy
'oAppt.GetInspector().WordEditor.Range.FormattedText.Paste
'oMail.Close False
'oAppt.ForwardAsVcal
'oAppt.Display
'oAppt.Send
oMail.Send
Application.StatusBar = "Saving invites (" & CStr(attendeeIndex) & "/" & CStr(attendeeCount) & ") " & attendeeEmail
'saveInvite oAppt, industryWS, attendeeRange
DoEvents
Next attendeeIndex
End Sub