/// <summary>
        /// Sets the contact's picture using the specified file.
        /// </summary>
        /// <param name="fileName">The name of the file that contains the picture.</param>
        public void SetContactPicture(string fileName)
        {
            EwsUtilities.ValidateMethodVersion(this.Service, ExchangeVersion.Exchange2010, "SetContactPicture");

            InternalRemoveContactPicture();
            FileAttachment fileAttachment = Attachments.AddFileAttachment(Path.GetFileName(fileName), fileName);

            fileAttachment.IsContactPhoto = true;
        }
        /// <summary>
        /// Sets the contact's picture using the specified stream.
        /// </summary>
        /// <param name="contentStream">The stream containing the picture.</param>
        public void SetContactPicture(Stream contentStream)
        {
            EwsUtilities.ValidateMethodVersion(this.Service, ExchangeVersion.Exchange2010, "SetContactPicture");

            InternalRemoveContactPicture();
            FileAttachment fileAttachment = Attachments.AddFileAttachment(ContactPictureName, contentStream);

            fileAttachment.IsContactPhoto = true;
        }
        /// <summary>
        /// Removes the contact's picture.
        /// </summary>
        public void RemoveContactPicture()
        {
            EwsUtilities.ValidateMethodVersion(this.Service, ExchangeVersion.Exchange2010, "RemoveContactPicture");

            if (!this.PropertyBag.IsPropertyLoaded(ContactSchema.Attachments))
            {
                throw new PropertyException(Strings.AttachmentCollectionNotLoaded);
            }

            InternalRemoveContactPicture();
        }
        /// <summary>
        /// Retrieves the file attachment that holds the contact's picture.
        /// </summary>
        /// <returns>The file attachment that holds the contact's picture.</returns>
        public FileAttachment GetContactPictureAttachment()
        {
            EwsUtilities.ValidateMethodVersion(this.Service, ExchangeVersion.Exchange2010, "GetContactPictureAttachment");

            if (!this.PropertyBag.IsPropertyLoaded(ContactSchema.Attachments))
            {
                throw new PropertyException(Strings.AttachmentCollectionNotLoaded);
            }

            foreach (FileAttachment fileAttachment in this.Attachments)
            {
                if (fileAttachment.IsContactPhoto)
                {
                    return(fileAttachment);
                }
            }
            return(null);
        }