2

我正在使用 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);
            }
4

0 回答 0