EWS api 编辑联系人照片
我正在使用 EWS api 添加联系信息,如下面的代码描述 在exchange2007服务器上.. 但如何添加联系人的照片?
CreateItemType createItemType = new CreateItemType();
// Because you are creating a contact, save the item in the Contacts folder.
createItemType.SavedItemFolderId = new TargetFolderIdType();
DistinguishedFolderIdType contactsFolder = new DistinguishedFolderIdType();
contactsFolder.Id = DistinguishedFolderIdNameType.contacts;
createItemType.SavedItemFolderId.Item = contactsFolder;
createItemType.Items = new NonEmptyArrayOfAllItemsType();
createItemType.Items.Items = new ItemType[1];
// Create a contact item type.
ContactItemType contactItemType = new ContactItemType();
// Set the relevant properties on the contact.
contactItemType.FileAs = contactInfo.KnownName;
// Set the contact name and job information.
contactItemType.Surname = contactInfo.SurName;
contactItemType.GivenName = contactInfo.Name;
contactItemType.CompanyName = contactInfo.CompanyName;
// Set a single e-mail address for the contact.
contactItemType.EmailAddresses = new EmailAddressDictionaryEntryType[1];
EmailAddressDictionaryEntryType address = new EmailAddressDictionaryEntryType();
address.Key = EmailAddressKeyType.EmailAddress1;
address.Value = contactInfo.EMail;
contactItemType.EmailAddresses[0] = address;
// Set a single contact physical address.
contactItemType.PhysicalAddresses = new PhysicalAddressDictionaryEntryType[1];
PhysicalAddressDictionaryEntryType physicalAddress = new PhysicalAddressDictionaryEntryType();
physicalAddress.City = contactInfo.City;
physicalAddress.PostalCode = contactInfo.PostalCode;
physicalAddress.Street = contactInfo.AdressDetail;
physicalAddress.CountryOrRegion = contactInfo.Country;
contactItemType.PhysicalAddresses[0] = physicalAddress;
*/
// Set the contact telephone numbers.
int phoneNumberCount = contactInfo.Phones.Count;
if (phoneNumberCount > 0)
{
contactItemType.PhoneNumbers = new PhoneNumberDictionaryEntryType[phoneNumberCount];
for (int i = 0; i < phoneNumberCount; i++)
{
PhoneNumberDictionaryEntryType phoneNumberDictionaryEntryType = new PhoneNumberDictionaryEntryType();
phoneNumberDictionaryEntryType.Key = (PhoneNumberKeyType)contactInfo.Phones[i].PhoneNumberType;
phoneNumberDictionaryEntryType.Value = contactInfo.Phones[i].PhoneNumber;
contactItemType.PhoneNumbers[i] = phoneNumberDictionaryEntryType;
}
}
createItemType.Items.Items[0] = contactItemType;
// Send the request to create the contact item; receive the response.
CreateItemResponseType createItemResponse = esb.CreateItem(createItemType);
// Check the results of the request.
if (createItemResponse.ResponseMessages.Items.Length > 0 &&
createItemResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success)
{
ItemInfoResponseMessageType responseMessage = createItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;
ContactItemType contactResponse = responseMessage.Items.Items[0] as ContactItemType;
//TO DO: log->contactResponse.ItemId.Id, contactResponse.ItemId.ChangeKey);
}
i'm using EWS api to add contact information as code description below
on exchange2007 server..
but how to add contact's photo ??
CreateItemType createItemType = new CreateItemType();
// Because you are creating a contact, save the item in the Contacts folder.
createItemType.SavedItemFolderId = new TargetFolderIdType();
DistinguishedFolderIdType contactsFolder = new DistinguishedFolderIdType();
contactsFolder.Id = DistinguishedFolderIdNameType.contacts;
createItemType.SavedItemFolderId.Item = contactsFolder;
createItemType.Items = new NonEmptyArrayOfAllItemsType();
createItemType.Items.Items = new ItemType[1];
// Create a contact item type.
ContactItemType contactItemType = new ContactItemType();
// Set the relevant properties on the contact.
contactItemType.FileAs = contactInfo.KnownName;
// Set the contact name and job information.
contactItemType.Surname = contactInfo.SurName;
contactItemType.GivenName = contactInfo.Name;
contactItemType.CompanyName = contactInfo.CompanyName;
// Set a single e-mail address for the contact.
contactItemType.EmailAddresses = new EmailAddressDictionaryEntryType[1];
EmailAddressDictionaryEntryType address = new EmailAddressDictionaryEntryType();
address.Key = EmailAddressKeyType.EmailAddress1;
address.Value = contactInfo.EMail;
contactItemType.EmailAddresses[0] = address;
// Set a single contact physical address.
contactItemType.PhysicalAddresses = new PhysicalAddressDictionaryEntryType[1];
PhysicalAddressDictionaryEntryType physicalAddress = new PhysicalAddressDictionaryEntryType();
physicalAddress.City = contactInfo.City;
physicalAddress.PostalCode = contactInfo.PostalCode;
physicalAddress.Street = contactInfo.AdressDetail;
physicalAddress.CountryOrRegion = contactInfo.Country;
contactItemType.PhysicalAddresses[0] = physicalAddress;
*/
// Set the contact telephone numbers.
int phoneNumberCount = contactInfo.Phones.Count;
if (phoneNumberCount > 0)
{
contactItemType.PhoneNumbers = new PhoneNumberDictionaryEntryType[phoneNumberCount];
for (int i = 0; i < phoneNumberCount; i++)
{
PhoneNumberDictionaryEntryType phoneNumberDictionaryEntryType = new PhoneNumberDictionaryEntryType();
phoneNumberDictionaryEntryType.Key = (PhoneNumberKeyType)contactInfo.Phones[i].PhoneNumberType;
phoneNumberDictionaryEntryType.Value = contactInfo.Phones[i].PhoneNumber;
contactItemType.PhoneNumbers[i] = phoneNumberDictionaryEntryType;
}
}
createItemType.Items.Items[0] = contactItemType;
// Send the request to create the contact item; receive the response.
CreateItemResponseType createItemResponse = esb.CreateItem(createItemType);
// Check the results of the request.
if (createItemResponse.ResponseMessages.Items.Length > 0 &&
createItemResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success)
{
ItemInfoResponseMessageType responseMessage = createItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;
ContactItemType contactResponse = responseMessage.Items.Items[0] as ContactItemType;
//TO DO: log->contactResponse.ItemId.Id, contactResponse.ItemId.ChangeKey);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论