Trap outlook calendar events in outlook meeting appointments in C#.Net


In this post, we will discuss how to trap outlook calendar events in outlook meeting appointments in C#.Net. Also, you can check out my previous posts on:
If you are working in outlook plugin application development then we need to catch the events of the calendar folder. Here the requirement is to save meeting details into SQL Server 2008 database.
But in case of a delete event, you will not get the GlobalAppointmentID of the meeting item. Follow below code:
using Office = Microsoft.Office.Core;
 public partial class ThisAddIn
{
        Microsoft.Office.Interop.Outlook.Application app = null;
        NameSpace ns = null;
        MAPIFolder calendar = null;
        Items appointments = null;
        private  Outlook.MAPIFolder DeletedItem;
        private  Outlook.Items itemDelete;
       private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            app = new Microsoft.Office.Interop.Outlook.Application();
            ns = app.GetNamespace(“mapi”);
            ns.Logon(“”, “”, true, true);
            calendar = ns.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
            appointments = calendar.Items;
            appointments.ItemAdd += new ItemsEvents_ItemAddEventHandler(appointments_ItemAdd);
            appointments.ItemChange += new ItemsEvents_ItemChangeEventHandler(appointments_ItemChange);
            appointments.ItemRemove += new ItemsEvents_ItemRemoveEventHandler(appointments_ItemRemove);
       }
      void itemDelete_ItemChange(object Item)
        {
            AppointmentItem appointment = (Item as AppointmentItem);
            Messageox.Show(appointment.GlobalAppointmentID);
        }
        void appointments_ItemRemove()
        {
            DeletedItem = ns.GetDefaultFolder(OlDefaultFolders.olFolderDeletedItems);
            itemDelete = DeletedItem.Items;
            itemDelete.ItemChange += new ItemsEvents_ItemChangeEventHandler(itemDelete_ItemChange);
        }
        void appointments_ItemChange(object Item)
        {
            AppointmentItem appointment = (Item as AppointmentItem);
            Messageox.Show(appointment.GlobalAppointmentID);
        }
        void appointments_ItemAdd(object Item)
        {
           AppointmentItem appointment = (Item as AppointmentItem);
            Messageox.Show(appointment.GlobalAppointmentID);
        }
}
Check out Best Alternative to InfoPath -> Try Now

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →