Using Microsoft Outlook API with C# to list calend

2019-06-07 17:48发布

问题:

I have found some Microsoft Resources about how to use the REST API to connect to an Outlook account. The sample tutorial they provided got me to create a WPF project and register an app with the Outlook Developer centre.

So I have done all of that and can connect to Outlook. It shows the content screen where the user must allow access. All good.

But I don't want to use WPF. Ideally I want to write a C# .NET DLL component what with communicate with the Outlook API so that I can specifically:

  • List Calendars
  • Add events to calendar
  • Delete events from calendar

I understand that I need to use the Microsoft.Graph library but I can't find out how to use this with C# .NET.

I am familiar with the Google Calendar API and have written a VB. NET command line utility that does the same things. So I was hoping to do things similarly.

The WPF tutorial stops at the "connect" stage so I am at a loss as to how to proceed. And the other example is here:

https://docs.microsoft.com/en-us/outlook/rest/dotnet-tutorial

That shows you how to write a utility with ASP.NET MVC Web app to get Outlook mail, calendar, and contacts. But again, I am confused as to how to do what I want with C#.NET DLL.

If it is possible to using the Microsoft.Graph library from C# DLL to list the calendars etc. I would appreciate guidance.

If there is a more direct resource I should point this question to then I would be more than happy to do so.

Thank you.

PS. Please note that I am referring to the online Outlook system and not the Microsoft Outlook on a user PC.

回答1:

There are a number of C# examples using the Microsoft Graph .NET SDK available on GitHub. There is a Console App example included in that list: ConsoleApp-DeltaQuery-DotNet-Sample.