ExchangeService service = this.GetService();
FolderId folderID = GetPublicFolderID(service, "My Address Book");
ContactsFolder folder = ContactsFolder.Bind(service, folderID);
int folderCount = folder.TotalCount;
var guid = DefaultExtendedPropertySet.PublicStrings;
var epdCP = new ExtendedPropertyDefinition(guid, "CustomProp", MapiPropertyType.Boolean);
var epdAccount = new ExtendedPropertyDefinition(guid, "Account", MapiPropertyType.String);
var epdCID = new ExtendedPropertyDefinition(guid, "CustomerID", MapiPropertyType.Integer);
var view = new ItemView(folderCount);
view.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties);
view.PropertySet.Add(epdCP);
view.PropertySet.Add(epdAccount);
view.PropertySet.Add(epdCID);
var contacts = service.FindItems(folderID, view);
foreach (Contact contact in contacts)
{
bool CP;
string Account;
int CID;
contact.GetLoadedPropertyDefinitions();
contact.TryGetProperty(epdCP, out CP);
contact.TryGetProperty(epdAccuont, out Account);
contact.TryGetProperty(epdCID, out CID);
Console.WriteLine(String.Format("{0, -20} - {1} - {2}"
, contact.DisplayName
, contact.EmailAddresses[EmailAddressKey.EmailAddress1]
, CP
, Account
, CID
));
}
Goal is to get the Contact information out of a Public Address Book so I can sync it with another program we have.
For each Contact in the Public Address Book, this prints out DisplayName, EmailAddress and my Custom Property. No issues there.
The problem I have is I can't seem to get the right incantation to pull certain properties. CustomerID and Account are two examples that I can't seem to get to pull/print. They aren't "Custom", in as much as I haven't created them.
How can I get CustomerID and Account out of a contact via EWS?