locked
Adding outlook appointment item to shared folder RRS feed

  • Question

  • I would like to add an appointment item to a shared folder that is type of calendar.  I am able to locate the folder I need by using the following C# code.

    Outlook.MAPIFolder GPUpgrades = this.Session.Folders[1].Folders[2].Folders[3];

    How do I modify this line to go to the correct calendar?

    Outlook.AppointmentItem ai = (Outlook.AppointmentItem)this.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);

     

    Wednesday, August 23, 2006 11:48 PM

Answers

  • Hello,

    I think you can do it if you have a reference to the folder you want to add it to...

    Outlook.AppointmentItem ai = (Outlook.AppointmentItem)GPUpgrades.Items.Add("IPM.XXXX");
    // Where XXXX is the type you want to add.  For my addin, its IPM.Post.
    // I am not exactly sure what the IPM.XXXX is for calendar items...

    Cheers,
    ~Joe

    Friday, August 25, 2006 9:01 PM

All replies

  • Hello,

    I think you can do it if you have a reference to the folder you want to add it to...

    Outlook.AppointmentItem ai = (Outlook.AppointmentItem)GPUpgrades.Items.Add("IPM.XXXX");
    // Where XXXX is the type you want to add.  For my addin, its IPM.Post.
    // I am not exactly sure what the IPM.XXXX is for calendar items...

    Cheers,
    ~Joe

    Friday, August 25, 2006 9:01 PM
  • Thanks Joe.

    Right now I am doing the items.add on the write event of another outlook appointment item.  I dont get an error, it looks like everything works...but doesnt actually write anything to that shared calendar.  Any thoughts on why?

    void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)

    {

        if ((Inspector.CurrentItem is Outlook.AppointmentItem))

        {

              //create event handler for save

             apptItem = (Outlook.AppointmentItem)Inspector.CurrentItem;

             apptItem.Write += new Microsoft.Office.Interop.Outlook.ItemEvents_10_WriteEventHandler(apptItem_Write);

       }

    }

    void apptItem_Write(ref bool cancel)

    {

       GPUpgrades.Items.Add(apptItem);

    }

    Monday, August 28, 2006 11:06 PM
  • Never mind previous post... I was able to get it working with the following code...

    Outlook._AppointmentItem ai = (Outlook._AppointmentItem)GPUpgrades.Items.Add(Outlook.OlItemType.olAppointmentItem);

    ai.Subject = apptItem.Subject;

    ai.Body = apptItem.Subject;

    ai.Start = apptItem.Start;

    ai.Duration = apptItem.Duration;

    ai.Save();

    ai.Close(Microsoft.Office.Interop.Outlook.OlInspectorClose.olSave);

    Tuesday, August 29, 2006 12:21 AM