VS2022 VSTO C# Outlook addIn - error System._ComObject when creating new meeting from Calendar
Hi, I am trying to create a C# VSTO Add In for outlook 2016 connected to Exchange 2016 (I know it's old but I am tied to these versions for now) - starting with something simple.
required function:
user creates a meeting in outlook calendar and invites users plus a conference room resource
when email of conference resource is detected all recipients receive an email with prepopulated conference details
NB: code works with MailItem but not AppointmentItem
I tried creating a new install of windows 11, with office 2016 (no previous versions installed) and error persisted.
error:
System.InvalidCastException: 'Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.AppointmentItem'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063033-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).'
This is generated in debug on the line in bold below
Outlook.AppointmentItem appointmentItem = (Outlook.AppointmentItem)item;