exchangewebservicesewsjavaapi

How to get a Flag property from email message?


Can I somehow get a Flag property from EmailMessage or Item object? There is no getFlag() method, I also didn't find it in item.getPropertyBag(). I'm using ews-java-api-2.0. flag setting on outlook web app


Solution

  • There is a strongly type flag property in EWS in 2013 and greater so you could modify the EWS Java source to cater for that. Otherwise if you use the underlying Extended properties you can get the same information eg

            ExtendedPropertyDefinition PR_FLAG_STATUS = new ExtendedPropertyDefinition(0x1090, MapiPropertyType.Integer);
            ExtendedPropertyDefinition FlagRequest = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Common, 0x8530, MapiPropertyType.String);
            PropertySet fiFindItemPropset = new PropertySet(BasePropertySet.FirstClassProperties);
            fiFindItemPropset.Add(FlagRequest);
            fiFindItemPropset.Add(PR_FLAG_STATUS);
            FolderId FolderToAccess = new FolderId(WellKnownFolderName.Inbox, MailboxToAccess);
            ItemView ivItemView = new ItemView(1000);
            ivItemView.PropertySet = fiFindItemPropset;
            FindItemsResults<Item> FindItemResults = null;
            do
            {
                FindItemResults = service.FindItems(FolderToAccess, ivItemView);
                foreach (Item itItem in FindItemResults.Items)
                {
                    Console.WriteLine(itItem.Subject);
                    Object FlagValue = null;
                    if (itItem.TryGetProperty(FlagRequest, out FlagValue))
                    {
                        Console.WriteLine("Flag : " + FlagValue);
                    }
                    Object PR_FLAG_STATUS_Value = null;
                    if (itItem.TryGetProperty(PR_FLAG_STATUS, out PR_FLAG_STATUS_Value))
                    {
                        Console.WriteLine("PR_FLAG_STATUS : " + PR_FLAG_STATUS_Value);
                    }
                }
                ivItemView.Offset += FindItemResults.Items.Count;
            } while (FindItemResults.MoreAvailable);
    

    Theres a full list of flag properties https://msdn.microsoft.com/en-us/library/ee201258(v=exchg.80).aspx