Search code examples
outlook-addinoutlook-redemption

Determine if an appointment item exists in a cached or online store


I'm attempting to determine if a appointment item exists in a cached of online mailbox store. My code runs too slowly in the online store so I'm trying to hide the ribbon button for online stores.

 public bool Control_Visible_AptDates(Office.IRibbonControl control)
    {

        if (control.Context is Outlook.Inspector)
        {
            Outlook.Inspector inspector = (Outlook.Inspector)control.Context;
            if (inspector.CurrentItem is Outlook.AppointmentItem)
            {
                
                Outlook.AppointmentItem aptItem = inspector.CurrentItem as Outlook.AppointmentItem;

                if (true)
                {
                    //If item stored online return false
                }
                else
                {
                    //If item stored in cached Exchange mailbox store return true
                }

What is the best way to determine if the item is online or using cached Exchange mode?

Using Outlook Spy, I can see that there's a PR_STORE_OFFLINE which seems to be the property that I'm looking for. It exists in cached items only as far as I can tell.

bool offline = aptItem.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x6632000B");

Can this property be read using PropertyAccessor somehow or is Redemption required?

If Redemption is required can you provide a code snippet to get me started?

Thanks in advance!

related images- enter image description here enter image description here


Solution

  • PR_STORE_OFFLINE is only available on the IMsgStore object, not on the items. You can try to use Application.Session.ExchangeConnectionMode property - see https://learn.microsoft.com/en-us/office/vba/api/outlook.namespace.exchangeconnectionmode.