2014-11-21 115 views
0

我正在使用办公室(Microsoft.Exchange.WebServices)获取有关office365联系人的数据。 我正确地得到所有信息除了电子邮件地址的名称。它们是空的。Office365连接器:电子邮件地址没有名称

我想我忘记了一个PropertySet,但我不知道哪一个。

所以这是我得到的数据的打印屏幕。您可以看到Id,MailboxType,Name和RoutingType全都为空。 Office data

这是功能我打电话来获取数据:

public ContactInConexio[] GetAll() 
{ 
    Debugger.Launch(); 
    var contactsFolder = ContactsFolder.Bind(_service, WellKnownFolderName.Contacts, 
     new PropertySet(BasePropertySet.IdOnly, FolderSchema.TotalCount)); 

    var numItems = contactsFolder.TotalCount; 

    if (numItems > 0) 
    { 
     var view = new ItemView(numItems) { PropertySet = _contactPropertySet }; 
     view.PropertySet = _contactPropertySet; 

     //SearchFilter filter = new SearchFilter.Exists(ContactSchema.CompanyName); 

     //This is the variable where I put the breakpoint. And the data of contactsItem is in the picture. 
     var contactsItems = contactsFolder.FindItems(view); 

     var officeContacts = 
      new List<ContactInOffice>(Array.ConvertAll(contactsItems.ToArray(), x => (ContactInOffice)x)); 

     return Array.ConvertAll(officeContacts.ToArray(), 
      officeContact => officeContact.ToConexioContact(new ContactInConexio())); 
    } 
    return new ContactInConexio[0]; 
} 

这里是属性集:

private readonly PropertySet _contactPropertySet = new PropertySet(BasePropertySet.IdOnly, 
     ContactSchema.DisplayName, 
     ContactSchema.CompleteName, ContactSchema.CompanyName, ContactSchema.Department, ContactSchema.JobTitle, 
     ContactSchema.Profession, ContactSchema.BusinessHomePage, ContactSchema.Birthday, ContactSchema.Photo, 
     ContactSchema.HasPicture, 
     ContactSchema.PrimaryPhone, ContactSchema.BusinessPhone, ContactSchema.HomePhone, 
     ContactSchema.OtherTelephone, 
     ContactSchema.CompanyMainPhone, ContactSchema.HomeFax, ContactSchema.BusinessFax, ContactSchema.OtherFax, 
     ContactSchema.MobilePhone, ContactSchema.CarPhone, ContactSchema.RadioPhone, ContactSchema.Pager, 
     ContactSchema.Isdn, 
     ContactSchema.Callback, ContactSchema.TtyTddPhone, ContactSchema.BusinessAddressCity, 
     ContactSchema.BusinessAddressCountryOrRegion, 
     ContactSchema.BusinessAddressPostalCode, ContactSchema.BusinessAddressState, 
     ContactSchema.BusinessAddressStreet, 
     ContactSchema.HomeAddressCity, ContactSchema.HomeAddressCountryOrRegion, ContactSchema.HomeAddressPostalCode, 
     ContactSchema.HomeAddressState, ContactSchema.HomeAddressStreet, ContactSchema.OtherAddressCity, 
     ContactSchema.OtherAddressCountryOrRegion, ContactSchema.OtherAddressPostalCode, 
     ContactSchema.OtherAddressState, 
     ContactSchema.OtherAddressStreet, ContactSchema.ImAddress1, ContactSchema.ImAddress2, 
     ContactSchema.ImAddress3, 
     ContactSchema.EmailAddress1, ContactSchema.EmailAddress2, ContactSchema.EmailAddress3, 
     ContactSchema.Birthday, 
     ContactSchema.Notes); 

正如你可以在图片和代码中看到,我没没有从办公室Web服务获取数据,但是当我在网页浏览器中进行API调用时,数据就在那里。那么我做错了什么?

这是在网页浏览器中的数据: Webbrowser

回答

1

下面的代码:

var contactsFolder = ContactsFolder.Bind(_service, WellKnownFolderName.Contacts, 
     new PropertySet(BasePropertySet.IdOnly, FolderSchema.TotalCount)); 

您应该BasePropertySet.FirstClassProperties代替BasePropertySet.IdOnly创建的属性集。因此它会返回这些属性。请按照链接了解详情。

相关问题