views:

165

answers:

1

Hi all 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);
            }
A: 

Anyone got a tip how to add a contact photo using EWS 2007?

Marco
hallo exchange 2007 and 2007 sp1 does not have a photo property this feature supported on exchange 2010 server...
dankyy1
but there is no workaround? i can't demand an upgrade from the server, just because of setting some contact photos...
Marco
in this case...u may have a work on backgroungd..hold photos as attachment of contact with named a special synax ..and your application show attachments named with this syntax as contact's picture
dankyy1