0

How to get custom field value of item in Outlook Public Folder? I need to do it in C# and preferably using ExchangeService and not Interop.

Do you have any code examples handy?

So far I am getting into desired Public Folder and can read item(s). However, I can't find any custom fields in properties.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Michal
  • 1
  • 1

1 Answers1

0

The following example shows how to retrieve a collection of items from the Exchange mailbox, including the extended property that is identified by the GUID. The example searches each retrieved item and displays the subject line of each item and the extended property name and value, if it exists.

// Retrieve a collection of all the mail (limited to 10 items) in the Inbox. View the extended property.
ItemView view = new ItemView(10);

// Get the GUID for the property set.
Guid MyPropertySetId = new Guid("{C11FF724-AA03-4555-9952-8FA248A11C3E}");

// Create a definition for the extended property.
ExtendedPropertyDefinition extendedPropertyDefinition =
  new ExtendedPropertyDefinition(MyPropertySetId, "Expiration Date", MapiPropertyType.String);

view.PropertySet = 
 new PropertySet(BasePropertySet.IdOnly, ItemSchema.Subject, extendedPropertyDefinition);

FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, view);
// Search the e-mail collection for the extended property.
foreach (Item item in findResults.Items)
{
    Console.WriteLine(item.Subject);
    if (item.ExtendedProperties.Count > 0)
    {   
        // Display the extended name and value of the extended property.
        foreach (ExtendedProperty extendedProperty in item.ExtendedProperties)
        {
            Console.WriteLine(" Extended Property Name: " + extendedProperty.PropertyDefinition.Name);
            Console.WriteLine(" Extended Property Value: " + extendedProperty.Value);
        }
    }
}

See Viewing custom extended properties by using the EWS Managed API 2.0 for more information.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45