Search code examples
c#outlook-addin

Outlook Interop: is there a way to check if an Outlook folder is read-only


I'm writing a piece of code in C# to get all writable Calendars from Outlook via Outlook Interop. The calendars in Outlook are just Outlook folders whose default item type is OlItemType.olAppointmentItem. However, there are always read-only Calendars such as the Birthday Calendar if you add your Hotmail account to Outlook.

Is there a way to detect these read-only Calendars?


Solution

  • So it looks like there's no dedicated method to check if the current user has permission to write to an outlook folder provided that it might not be an exchange folder. Therefore the most reliable way is probably try creating and deleting a dummy item:

    try
    {
        ((AppointmentItem)calendarFolder.Items.Add(OlItemType.olAppointmentItem)).Delete();
    
        // Do whatever you need with this folder.
    }
    catch
    {
        // This probably means the folder is not writeable.
    }
    

    Note that the item type needs to match the folder default item type.