Steve Borland
Steve Borland

Reputation: 380

How to retrieve appointments in UWP from a Windows 10 calendar using C#

I'm creating a Universal Windows Application in windows 10 using C# which manages appointments in the Windows Calendar App. I am able to add appointments, and can edit or delete them using the ID. However, without retrieving them and filtering, I won't know their ID.

Has anybody had any experience with retrieving a list of calendar appointments in Windows 10 using C#?

Upvotes: 2

Views: 1631

Answers (2)

Dani Pazos
Dani Pazos

Reputation: 126

You can retrieve all the calendar appointments using the Windows.ApplicationModel.Appointments.AppointmentStore class.

In this example I am going to retrieve the appointments in the next 24 hours

AppointmentStore appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);

var dateToShow = DateTime.Now.AddDays(0);
var duration = TimeSpan.FromHours(24);

var appCalendars = await appointmentStore.FindAppointmentsAsync(dateToShow, duration);
foreach (var calendar in appCalendars)
{
[...]
}

Remember to grant access to Apointments Capabilities in the package.appxmanifest

Upvotes: 5

acidbabies
acidbabies

Reputation: 107

According to MSDN:

Through the Windows.ApplicationModel.Appointments namespace, you can create and manage appointments in a user's calendar app.

Upvotes: 0

Related Questions