In the last blog post, we learnt “How to Share a Media File from WP8 using the ShareMediaTask?” which was a launcher available in Windows Phone 8 SDK. Similarly there are few more launchers available in the SDK by which you can launch WP8 specific applications programmatically.

 

Today in this blog post we will learn how to create an appointment in Windows Phone 8 using the API named “SaveAppointmentTask”. Continue reading for details.

 

Implementation Steps

Windows Phone 8 SDK provides you an API named SaveAppointmentTask, which helps you to create an appointment programmatically from your Windows Phone 8 application. The said class is present in the “Microsoft.Phone.Tasks” namespace. SaveAppointmentTask is actually a launcher which launches a dialog that allows a user to create and save appointment with predefined values.

 

To begin with the implementation steps, first create an instance of the SaveAppointmentTask present under the namespace named “Microsoft.Phone.Tasks” and then fill up the fields those you want to populate from your application itself. After that, call the Show() method of the SaveAppointmentTask to launch the phone application. Here is the sample code for your reference:

 

var saveAppointmentTask = new SaveAppointmentTask();
 
saveAppointmentTask.StartTime = DateTime.Now.AddHours(1);
saveAppointmentTask.EndTime = DateTime.Now.AddHours(2);
saveAppointmentTask.Subject = "Save Appointment Task Demo";
saveAppointmentTask.Location = "www.kunal-chowdhury.com";
saveAppointmentTask.Details = "Demo uses of SaveAppointmentTask to the WP8Devs";
saveAppointmentTask.IsAllDayEvent = false;
saveAppointmentTask.Reminder = Reminder.FifteenMinutes;
saveAppointmentTask.AppointmentStatus = Microsoft.Phone.UserData.AppointmentStatus.Busy;
 
saveAppointmentTask.Show();

 

Once you call the Show() method, it will open the Appointment client in the screen with the predefined values and ask the user to verify/modify them. Clicking the save button will then actually save the appointment to the user’s phone calendar.

 

Here is the meta data of the “SaveAppointmentTask” class:

 

namespace Microsoft.Phone.Tasks
{
    public sealed class SaveAppointmentTask
    {
        public DateTime? StartTime { get; set; }
        public DateTime? EndTime { get; set; }
        public bool IsAllDayEvent { get; set; }
        public string Subject { get; set; }
        public string Location { get; set; }
        public string Details { get; set; }
        public Reminder Reminder { get; set; }
        public AppointmentStatus AppointmentStatus { get; set; }
        
        public void Show();
    }
}

 

Keep in mind that, you can not silently create an appointment as the user interaction is needed for security reason and that is defined by the Microsoft Windows Phone 8 SDK.

 

I hope that the post was helpful and helped you to integrate the appointment creation task in your phone programmatically from your application. Let me know, if you have further queries on this. I will try to answer you as soon as I can.

 

Are you on Twitter? Don’t forget to connect with me. I am also available in Facebook and Google+. Stay connected. Feel free to subscribe to my blog’s RSS feed and email newsletter to get all article updates directly delivered to your inbox.

Have a question? Or, a comment? Let's Discuss it below...

Thank you for visiting our website!

We value your engagement and would love to hear your thoughts. Don't forget to leave a comment below to share your feedback, opinions, or questions.

We believe in fostering an interactive and inclusive community, and your comments play a crucial role in creating that environment.