How to create appointment with all in Outlook c#

Viewed 108

I have troubles with sending appointments to shared calendar programatically. I know that the standard way is as below:

MAPIFolder sharedFolder = mapiNamespace.GetSharedDefaultFolder(recipient, OlDefaultFolders.olFolderCalendar);
Outlook.AppointmentItem newAppointment = sharedFolder.Items.Add(Outlook.OlItemType.olAppointmentItem) as Outlook.AppointmentItem;
//Outlook.AppointmentItem newAppointment = sharedFolder.Items.Add("IPM.Appointment"); ///Second option
 

But probably it is equal to clicking into shared calendar and require write rights.

I need to do it as below in GUI, this allow to send appointment even if I do not have write rights:

NOTE: (In English) New appointment --> New appointment with all

enter image description here

NOTE2: If I send it by standard way (see code below), it will not send it to shared folder.

Outlook.AppointmentItem newAppointment = (Outlook.AppointmentItem)application.CreateItem(Outlook.OlItemType.olAppointmentItem);
newAppointment.Start = startT;// DateTime.Now.AddHours(2);
newAppointment.End = stopT;
newAppointment.Subject = name;
newAppointment.Location = loc;
newAppointment.Body = body;
newAppointment.AllDayEvent = false;
//newAppointment.Recipients.Add(application.Session.CurrentUser.Name);
for (int i = 0; i < rec.Count; i++) newAppointment.Recipients.Add(rec[i]);
Outlook.Recipients sentTo = newAppointment.Recipients;
sentTo.ResolveAll();
newAppointment.Save();
newAppointment.Display(true);
newAppointment.Send();
newAppointment.Close(OlInspectorClose.olSave);

Thank you in advance for your answers.

1 Answers

You need to add the mailbox owner as an attendee and send it:

newAppointment.Recipients.Add(recipient);
newAppointment.Send();
Related