Reputation: 4333
I am using the office(Microsoft.Exchange.WebServices
) to get data about contacts on office365.
I get all the information correctly except the names from the emailaddresses. They are null.
I think I forgot a PropertySet for that but I don't know which one.
So this is a printscreen of the data that I get. As you can see the Id, MailboxType, Name and RoutingType are all null.
This is the function I call to get the 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];
}
Here is the PropertySet:
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);
As you can see in the picture and the code, I didn't get the data from the office Webservice but when I do an API call in the webbrowser, the data is there. So what am I doing wrong?
This is the data in the webbrowser:
Upvotes: 0
Views: 105
Reputation: 6050
The code below:
var contactsFolder = ContactsFolder.Bind(_service, WellKnownFolderName.Contacts,
new PropertySet(BasePropertySet.IdOnly, FolderSchema.TotalCount));
You should create the PropertySet with BasePropertySet.FirstClassProperties instead of BasePropertySet.IdOnly. Thus it will return these properties. Please follow the link for the details.
Upvotes: 1