无法访问联系人 phone 号码
Cannot access contact phone numbers
我正在使用 EWS API 访问联系人,
但无法访问联系人 phone 号码!
看起来 ContactSchema.PhoneNumbers 在 view.Property 中不被接受
目前我有:
ItemView view = new ItemView(numItems);
view.PropertySet = new PropertySet(BasePropertySet.IdOnly, new PropertyDefinitionBase[] { ContactSchema.DisplayName} );
PropertySet PropSet = new PropertySet();
PropSet.Add(ContactSchema.DisplayName);
PropSet.Add(ContactSchema.PhoneNumbers);
FindItemsResults<Item> findResults;
do
{
findResults = service.FindItems(WellKnownFolderName.Contacts, view);
if (findResults.Items.Count > 0)
{
service.LoadPropertiesForItems(findResults.Items, PropSet);
foreach (var item in findResults.Items)
{
// Display the list of contacts.
if (item is Contact)
{
Contact contact = item as Contact;
PhoneNumberDictionary ph = contact.PhoneNumbers;
// ph is empty here!
}
}
}
view.Offset += findResults.Items.Count;
} while (findResults.MoreAvailable);
伙计,你就快完成了,只需将你希望 read/write 的每个 phone 号码类型添加到 属性 集合中即可!
Private ReadOnly PhoneFields As PropertySet = New PropertySet(ContactSchema.PhoneNumbers, ContactSchema.MobilePhone, ContactSchema.CarPhone, ContactSchema.HomePhone,
ContactSchema.HomePhone2, ContactSchema.HomePhone2, ContactSchema.BusinessPhone, ContactSchema.BusinessPhone2,
ContactSchema.BusinessFax, ContactSchema.OtherFax, ContactSchema.HomeFax, ContactSchema.Pager,
ContactSchema.OtherTelephone, ContactSchema.Callback, ContactSchema.CompanyMainPhone, ContactSchema.PrimaryPhone,
ContactSchema.AssistantPhone, ContactSchema.RadioPhone, ContactSchema.TtyTddPhone, ContactSchema.Telex)
等等等等
我刚刚建立了一个联系人同步 Windows 服务任何问题都可以问我 twittet @rojobo
我正在使用 EWS API 访问联系人, 但无法访问联系人 phone 号码!
看起来 ContactSchema.PhoneNumbers 在 view.Property 中不被接受
目前我有:
ItemView view = new ItemView(numItems);
view.PropertySet = new PropertySet(BasePropertySet.IdOnly, new PropertyDefinitionBase[] { ContactSchema.DisplayName} );
PropertySet PropSet = new PropertySet();
PropSet.Add(ContactSchema.DisplayName);
PropSet.Add(ContactSchema.PhoneNumbers);
FindItemsResults<Item> findResults;
do
{
findResults = service.FindItems(WellKnownFolderName.Contacts, view);
if (findResults.Items.Count > 0)
{
service.LoadPropertiesForItems(findResults.Items, PropSet);
foreach (var item in findResults.Items)
{
// Display the list of contacts.
if (item is Contact)
{
Contact contact = item as Contact;
PhoneNumberDictionary ph = contact.PhoneNumbers;
// ph is empty here!
}
}
}
view.Offset += findResults.Items.Count;
} while (findResults.MoreAvailable);
伙计,你就快完成了,只需将你希望 read/write 的每个 phone 号码类型添加到 属性 集合中即可!
Private ReadOnly PhoneFields As PropertySet = New PropertySet(ContactSchema.PhoneNumbers, ContactSchema.MobilePhone, ContactSchema.CarPhone, ContactSchema.HomePhone,
ContactSchema.HomePhone2, ContactSchema.HomePhone2, ContactSchema.BusinessPhone, ContactSchema.BusinessPhone2,
ContactSchema.BusinessFax, ContactSchema.OtherFax, ContactSchema.HomeFax, ContactSchema.Pager,
ContactSchema.OtherTelephone, ContactSchema.Callback, ContactSchema.CompanyMainPhone, ContactSchema.PrimaryPhone,
ContactSchema.AssistantPhone, ContactSchema.RadioPhone, ContactSchema.TtyTddPhone, ContactSchema.Telex)
等等等等
我刚刚建立了一个联系人同步 Windows 服务任何问题都可以问我 twittet @rojobo