Friday, February 24, 2012

Tracking Meeting Request Events in Outlook

-Suresh Pitchai
Most of us use Outlook client application for mailing purpose where we also schedule meeting. The person who is going to organize the meeting will send request to the attendees. The receiver who receives the request may or may not accept the request. The sender will not be aware whether the meeting request has been accepted or declined by the receiver. In order to overcome this we have a mechanism for tracking the request and notify the sender.  
As I .Net Developer, I have written a small plug-in to solve this problem. I have achieved this by using the COM Component of ‘Microsoft. Office.Interop.Outlook’. This COM Component provides set of delegate events like ItemEvents_11, ApplicationEvents_11 etc., which has the methods ItemAdd, ItemChange, ItemRemove etc., In order to implement we can follow the below steps and sample code is given at the end.

Step 1: First get all appointments in Outlook Application. By using the below sample code , we get all the appointments of outlook application.

     NameSpace nameSpace = null;
     MAPIFolder calendar = null;
     Items outlookAppointments = null;
     public void OnStartupComplete(ref System.Array custom)
     {
      nameSpace = app.GetNamespace("mapi");
      nameSpace.Logon("", "", true, true);
      calendar = nameSpace.GetDefaultFolder
      (OlDefaultFolders.olFolderCalendar);
 outlookAppointments = calendar.Items;
     }
The above code is used to get all the appointment list objects. This object is stored in “outlookAppointments” items objects.

Step 2: Register the ItemAdd event in the “OnStartupComplete” Method

outlookAppointments.ItemAdd += new ItemsEvents_ItemAddEventHandler(outlookAppointments_ItemAdd)

The ItemsEvents_ItemAddEventHandler event is used to get the latest meeting request from your outlook application. The new meeting request added in your outlook, automatically triggers the “outlookAppointments_ItemAdd” method. Similarly to register the ItemChange, ItemRemove are as follows:

//this event trigger, when the meeting request change    
outlookAppointments.ItemChange += new ItemsEvents_ItemChangeEventHandler(outlookAppointments_ItemChange);

//this event trigger, when the meeting request decline or deleted.
outlookAppointments.ItemRemove += new ItemsEvents_ItemRemoveEventHandler(outlookAppointments_ItemRemove);


Step 3: Add the below method in your page.
       
       void outlookAppointments_ItemAdd(object Item)
     void outlookAppointments_ItemChange(object Item)
     void outlookAppointments_ItemRemove()

You can get details about the appointment body, duration, start time, end time, decline date, accepted date and etc., using the “item” object. The below sample code is used to get the some details.
          
     void outlookAppointments_ItemChange(object Item)
     {
      AppointmentItem appointment = (Item as AppointmentItem);
      string AppointmentDetails = string.Empty;
      AppointmentDetails = AppointmentDetails + "Subject :: " +
      appointment.Subject + "\r\n";
      AppointmentDetails = AppointmentDetails + "Body :: " +
      appointment.Body +     
      "\r\n";
      AppointmentDetails = AppointmentDetails + "Action :: " +
      appointment.Action.ToString() + "\r\n";
     }
This gives information about the receivers action.








1 comment:

data recovery services dallas said...

Marvelous work.Just wanted to drop a comment and say I am new to your blog and really like what I am reading.