none
Outlook 2013 - Cannot access categories of appointment item RRS feed

  • Question

  • Hello,

    I'm making customizations for Outlook 2013.

    I have a context menu item when user clicks on calendar item. If item is appointment I want to check categories of that appointment. But when I try to do that I get error:

    '((Microsoft.Office.Interop.Outlook.AppointmentItem)(appointment)).Categories' threw an exception of type 'System.Runtime.InteropServices.COMException'

    Here is my code for accessing categories:

                Outlook.Explorer explorer = ThisAddIn.application.ActiveExplorer();
    
                Outlook.Selection selection = explorer.Selection;
    
                if (selection.Count == 1)
                {
                    if (selection[1] is Outlook.AppointmentItem)
                    {
                        Outlook.AppointmentItem appointment = (selection[1] as Outlook.AppointmentItem);
    
                        return appointment.Categories;
                    }
                    else
                    {
                        return null;
                    }
                }

    Tuesday, November 5, 2013 10:01 AM

Answers

  • Hi,

    I reproduce your issue, and I tested it though the same way in VBA,it can get appointment.Categories and no exception was occured. I'm consulting to some senior engineers.I will continue to follow this issue.

    In addition ,I worte a workaround for you reference:

    Object selObject = this.Application.ActiveExplorer().Selection[1];
    Outlook.AppointmentItem apptItem =(selObject as Outlook.AppointmentItem);
    Outlook.Items  appointItems = this.Application.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar).Items;
    Outlook.AppointmentItem appointItem = appointItems[apptItem.Subject];
    

    It will get the categories from the calendar folder though the AppointmentItem.Subject.

    Regards &Thanks,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 11, 2013 3:06 AM

All replies

  • What is the COM exception error code?

    Can you see categories in OutlookSpy (click IMessage and Item)?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, November 7, 2013 4:03 AM
  • Hi,

    I reproduce your issue, and I tested it though the same way in VBA,it can get appointment.Categories and no exception was occured. I'm consulting to some senior engineers.I will continue to follow this issue.

    In addition ,I worte a workaround for you reference:

    Object selObject = this.Application.ActiveExplorer().Selection[1];
    Outlook.AppointmentItem apptItem =(selObject as Outlook.AppointmentItem);
    Outlook.Items  appointItems = this.Application.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar).Items;
    Outlook.AppointmentItem appointItem = appointItems[apptItem.Subject];
    

    It will get the categories from the calendar folder though the AppointmentItem.Subject.

    Regards &Thanks,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 11, 2013 3:06 AM