create an appointment on an Office365 group calendar programmatically

%3CLINGO-SUB%20id%3D%22lingo-sub-434357%22%20slang%3D%22en-US%22%3Ecreate%20an%20appointment%20on%20an%20Office365%20group%20calendar%26nbsp%3Bprogrammatically%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-434357%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20create%20an%20%3CSTRONG%3Eappointment%3C%2FSTRONG%3E%20on%20an%20Office365%20group%20%3CSTRONG%3Ecalendar%26nbsp%3B%3C%2FSTRONG%3Eprogrammatically.%26nbsp%3B%20I%20am%20able%20to%20get%20it%20through%20Outlook%20for%20Windows%2FOWA%20(New%20UI).%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F108258i52D9B19BD85365EE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22WeChat%20Screenshot_20190411140322.png%22%20title%3D%22WeChat%20Screenshot_20190411140322.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EAnd%20OWA%3A%20%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F108259i2EA87DD5A5D477E2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22WeChat%20Screenshot_20190411140724.png%22%20title%3D%22WeChat%20Screenshot_20190411140724.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ei%20retrieve%20the%20appointment%20via%20MS%20Graph%20API%20%3A%3C%2FP%3E%3CBLOCKQUOTE%3E%3CP%3E%22attendees%22%3A%20%5B%5D%2C%3CBR%20%2F%3E%22organizer%22%3A%20%7B%3CBR%20%2F%3E%22emailAddress%22%3A%20%7B%3CBR%20%2F%3E%22name%22%3A%20%22test11appointment%22%2C%3CBR%20%2F%3E%22address%22%3A%20%22test11%40haxia.onmicrosoft.com%22%3CBR%20%2F%3E%7D%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3CP%3ESo%20i%20post%20the%20similar%20json%20body%20and%20want%20to%20create%20a%20group%20appointment%20via%20MS%20Graph%20API%2C%20but%20it%20will%20automatically%20include%20the%26nbsp%3Bevent%20creator%20(the%20current%20sign-in%20user)%20as%20one%20attendee%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CBLOCKQUOTE%3E%3CP%3E%22attendees%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22type%22%3A%20%22required%22%2C%3CBR%20%2F%3E%22status%22%3A%20%7B%3CBR%20%2F%3E%22response%22%3A%20%22none%22%2C%3CBR%20%2F%3E%22time%22%3A%20%220001-01-01T00%3A00%3A00Z%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22emailAddress%22%3A%20%7B%3CBR%20%2F%3E%22name%22%3A%20%22test11appointment%22%2C%3CBR%20%2F%3E%22address%22%3A%20%22test11%40haxia.onmicrosoft.com%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22type%22%3A%20%22required%22%2C%3CBR%20%2F%3E%22status%22%3A%20%7B%3CBR%20%2F%3E%22response%22%3A%20%22none%22%2C%3CBR%20%2F%3E%22time%22%3A%20%220001-01-01T00%3A00%3A00Z%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22emailAddress%22%3A%20%7B%3CBR%20%2F%3E%22name%22%3A%20%22wyd%22%2C%3CBR%20%2F%3E%22address%22%3A%20%22jjj%40haxia.onmicrosoft.com%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%5D%2C%3CBR%20%2F%3E%22organizer%22%3A%20%7B%3CBR%20%2F%3E%22emailAddress%22%3A%20%7B%3CBR%20%2F%3E%22name%22%3A%20%22test11appointment%22%2C%3CBR%20%2F%3E%22address%22%3A%20%22test11%40haxia.onmicrosoft.com%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3CP%3Ethis%20will%20cause%20the%20event%20shows%20as%20a%20meeting%20instead%20of%20appointment.%20Then%20it%20will%20send%20invitations%20to%20group%20members%2C%20this%20annoyed%20me%20a%20lot.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20I%20trace%20the%20log%20of%20Outlook%20for%20Windows%2FOWA%20(New%20UI).%26nbsp%3B%20i%20find%20that%26nbsp%3BOutlook%20for%20Windows%20uses%20EWS%20to%20create%20appointments.%20i%20tried%20the%20following%20code%20%3A%3C%2FP%3E%3CDIV%20class%3D%22container%22%3E%3CDIV%20class%3D%22line%20number1%20index0%20alt2%22%3EExchangeService%20exchService%20%3D%20new%20ExchangeService(ExchangeVersion.Exchange2013_SP1)%3B%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number2%20index1%20alt1%22%3EexchService.UseDefaultCredentials%20%3D%20false%3B%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number3%20index2%20alt2%22%3EexchService.Credentials%20%3D%20new%20NetworkCredential(%22admin%40o365domain.com%22%2C%20%22pwd%22)%3B%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number4%20index3%20alt1%22%3EexchService.Url%20%3D%20new%20Uri(%22%3CA%20href%3D%22https%3A%2F%2Foutlook.office365.com%2FEws%2FExchange.asmx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Foutlook.office365.com%2FEws%2FExchange.asmx%3C%2FA%3E%22)%3B%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number5%20index4%20alt2%22%3EexchService.PreAuthenticate%20%3D%20false%3B%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number6%20index5%20alt1%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number7%20index6%20alt2%22%3EAppointment%20appointment%20%3D%20new%20Appointment(exchService)%3B%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number8%20index7%20alt1%22%3E%2F%2F%20Set%20the%20properties%20on%20the%20appointment%20object%20to%20create%20the%20appointment.%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number9%20index8%20alt2%22%3Eappointment.Subject%20%3D%20%22Sales%20Meeting%22%3B%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number10%20index9%20alt1%22%3Eappointment.Body%20%3D%20%22Focus%20on%20pre-sale%20and%20marketing.%22%3B%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number11%20index10%20alt2%22%3Eappointment.Start%20%3D%20DateTime.Now.AddDays(2)%3B%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number12%20index11%20alt1%22%3Eappointment.End%20%3D%20DateTime.Now.AddDays(2).AddHours(3)%3B%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number13%20index12%20alt2%22%3Eappointment.Location%20%3D%20%22Room%20111%22%3B%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number14%20index13%20alt1%22%3Eappointment.ReminderMinutesBeforeStart%20%3D%20240%3B%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number15%20index14%20alt2%22%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number17%20index16%20alt2%22%3E%2F%2F%20Bind%20the%20specified%20group%20calendar%20folder.%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number18%20index17%20alt1%22%3EFolder%20calendar_Folder%20%3D%20Folder.Bind(exchService%2C%20new%20FolderId(WellKnownFolderName.Calendar%2C%20%22salesboard%40o365domain.com%22))%3B%3C%2FDIV%3E%3CDIV%20class%3D%22line%20number19%20index18%20alt2%22%3Eappointment.Save(calendar_Folder.Id%2C%20SendInvitationsMode.SendToNone)%3B%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEven%20though%20it%20could%20prevent%20sending%20invitations%20but%20it%20still%20will%20involve%26nbsp%3Badmin%40o365domain.com%20as%20one%20attendee.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20for%20the%20new%20OWA%2C%20i%20find%20it%20in%20fact%20use%20the%20following%20web%20service%3A%3C%2FP%3E%3CBLOCKQUOTE%3E%3CP%3E%3CSPAN%20class%3D%22tabpanel-summary-value%20textbox-input%20devtools-monospace%22%3E%3CA%20href%3D%22https%3A%2F%2Foutlook.office365.com%2Fowa%2Fservice.svc%3Faction%3D%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Foutlook.office365.com%2Fowa%2Fservice.svc%3Faction%3D%3C%2FA%3E.....%3C%2FSPAN%3E%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3CP%3Ei%20did%20not%20find%20any%20docs%20about%20this%20service%20url.%26nbsp%3B%20Can%20someone%20help%20me%3F%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-434357%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExchange%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-856525%22%20slang%3D%22en-US%22%3ERe%3A%20create%20an%20appointment%20on%20an%20Office365%20group%20calendar%26nbsp%3Bprogrammatically%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-856525%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F136170%22%20target%3D%22_blank%22%3E%40kong%20mengfei%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22tlid-translation%20translation%22%3E%3CSPAN%20class%3D%22%22%3EIn%20my%20research%20on%20the%20net%2C%20I%20found%20%3C%2FSPAN%3E%3C%2FSPAN%3Exchange%20Web%20Services%20.NET%20Core%20API%20for%20Microsoft%20Exchange%20server%20and%20Office%20365%2FExchange%20Online.%20The%20API%20offers%20complete%20Exchange%20Web%20Services%20functionality%20including%20the%20ability%20to%20work%20with%20appointment.%20There%20are%20a%20number%20of%20use%20cases%20on%20the%20site%20and%20the%20API%20itself%20is%20well%20documented.%20Link%20is%20%3CA%20href%3D%22http%3A%2F%2Fwww.independentsoft.de%2Fexchangewebservices%2Ftutorial%2Fcreateappointment.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.independentsoft.de%2Fexchangewebservices%2Ftutorial%2Fcreateappointment.html%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi All,

 

I am trying to create an appointment on an Office365 group calendar programmatically.  I am able to get it through Outlook for Windows/OWA (New UI). 

WeChat Screenshot_20190411140322.png

And OWA: WeChat Screenshot_20190411140724.png

 

i retrieve the appointment via MS Graph API :

"attendees": [],
"organizer": {
"emailAddress": {
"name": "test11appointment",
"address": "test11@haxia.onmicrosoft.com"
}

So i post the similar json body and want to create a group appointment via MS Graph API, but it will automatically include the event creator (the current sign-in user) as one attendee:

 

"attendees": [
{
"type": "required",
"status": {
"response": "none",
"time": "0001-01-01T00:00:00Z"
},
"emailAddress": {
"name": "test11appointment",
"address": "test11@haxia.onmicrosoft.com"
}
},
{
"type": "required",
"status": {
"response": "none",
"time": "0001-01-01T00:00:00Z"
},
"emailAddress": {
"name": "wyd",
"address": "jjj@haxia.onmicrosoft.com"
}
}
],
"organizer": {
"emailAddress": {
"name": "test11appointment",
"address": "test11@haxia.onmicrosoft.com"
}
}

this will cause the event shows as a meeting instead of appointment. Then it will send invitations to group members, this annoyed me a lot.  

 

So I trace the log of Outlook for Windows/OWA (New UI).  i find that Outlook for Windows uses EWS to create appointments. i tried the following code :

ExchangeService exchService = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
exchService.UseDefaultCredentials = false;
exchService.Credentials = new NetworkCredential("admin@o365domain.com", "pwd");
exchService.PreAuthenticate = false;
   
Appointment appointment = new Appointment(exchService);
// Set the properties on the appointment object to create the appointment.
appointment.Subject = "Sales Meeting";
appointment.Body = "Focus on pre-sale and marketing.";
appointment.Start = DateTime.Now.AddDays(2);
appointment.End = DateTime.Now.AddDays(2).AddHours(3);
appointment.Location = "Room 111";
appointment.ReminderMinutesBeforeStart = 240;
 
// Bind the specified group calendar folder.
Folder calendar_Folder = Folder.Bind(exchService, new FolderId(WellKnownFolderName.Calendar, "salesboard@o365domain.com"));
appointment.Save(calendar_Folder.Id, SendInvitationsMode.SendToNone);

 

Even though it could prevent sending invitations but it still will involve admin@o365domain.com as one attendee. 

 

As for the new OWA, i find it in fact use the following web service:

https://outlook.office365.com/owa/service.svc?action=.....

i did not find any docs about this service url.  Can someone help me?  

1 Reply
Highlighted

Hi @kong mengfei,

In my research on the net, I found xchange Web Services .NET Core API for Microsoft Exchange server and Office 365/Exchange Online. The API offers complete Exchange Web Services functionality including the ability to work with appointment. There are a number of use cases on the site and the API itself is well documented. Link is http://www.independentsoft.de/exchangewebservices/tutorial/createappointment.html