Search code examples
c#outlookoffice-interop

Can you access forms in Outlook AppointmentItem in C#?


I am accessing an Outlook calendar using c# and office.interOp.

Within Outlook Calendar, the Outlook developer tools allow you to add forms to appointments. This capability is used extensively within my organisation.

Is there a way to access these form fields from inside c# using the AppointmentItem object? If so, how do I achieve this?


Solution

  • If you mean that you want to access any field on the object (including user defined fields):

        private object GetPropertyValue(AppointmentItem item, string propertyName)
        {
            ItemProperty property = item.ItemProperties[propertyName];
            return property.Value;
        }
    

    If you want to access to other form fields (Name, category, sub categories, etc...)

         AppointmentItem item = (AppointmentItem)Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderCalendar).Items.GetFirst();
         string category = item.FormDescription.Category;
         string subCategory = item.FormDescription.CategorySub;
         //...
    

    Hope that helps