How to Get the List of Appointments from the Calendar App in Windows Phone using C# ?

Published on July 31, 2014 by abundantcode

Filed under Windows Phone

Last modified July 31, 2014

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 3531 times

If you want to programmatically get the list of appointments from the calendar application of your Windows Phone device programmatically , you can use the Microsoft.Phone.UserData.Appointments.

How to Get the List of Appointments from the Calender App in Windows Phone using C# ?

Enable the ID_CAP_APPOINTMENTS in the WMAppManifest file and then create an instance of the Appointments class and call the SearchAsync method with the necessary parameters . Also add the SearchCompleted event handler.

Below is a sample code snippet demonstrating how to get the List of Appointments programmatically using C#.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using AbundantcodeWindowsPhone8Tutorial.Resources;
using Microsoft.Phone.Tasks;
using Microsoft.Phone.UserData;

namespace AbundantcodeWindowsPhone8Tutorial
{
    public partial class MainPage : PhoneApplicationPage
    {
        public MainPage()
        {
            InitializeComponent();
        }
        List<Appointment> LstAppointments;
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DateTime StartDate = DateTime.Now.AddDays(1);
            DateTime EndDate = DateTime.Now.AddDays(10);
            Appointments apps = new Appointments();
            apps.SearchCompleted += apps_SearchCompleted;
            apps.SearchAsync(StartDate,EndDate,null);
        }

        void apps_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            LstAppointments = new List<Appointment>(e.Results);
        }
    }
}

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Comment


x

You might be Interested in these Posts

C# and Lambda - Finding all the elements of an integer array less than 35

Here's a sample code snippet demonstrating how to find all the elements of an integer array that is ...

C# and LINQ - Finding all the elements of an integer array less than 35

Here's a sample code snippet demonstrating how to find all the elements of an integer array that is ...

How to hide horizontal or vertical scroll bar using VBA Code in Excel ?

Here's a VBA code that hides the horizontal and vertical scroll bar in Microsoft Excel. How to hide...