EWS api 编辑联系人照片

发布于 2024-08-23 02:33:29 字数 3781 浏览 6 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文