GetContactPictureAttachment method

FileAttachment? GetContactPictureAttachment()
The stream containing the picture. The name of the file that contains the picture. Retrieves the file attachment that holds the contact's picture.

Implementation

/// </summary>
/// <param name="contentStream">The stream containing the picture.</param>
// void SetContactPicture(Stream contentStream)
//        {
//            EwsUtilities.ValidateMethodVersion(this.Service, ExchangeVersion.Exchange2010, "SetContactPicture");
//
//            InternalRemoveContactPicture();
//            FileAttachment fileAttachment = Attachments.AddFileAttachment(ContactPictureName, contentStream);
//            fileAttachment.IsContactPhoto = true;
//        }

/// <summary>

/// </summary>
/// <param name="fileName">The name of the file that contains the picture.</param>
// void SetContactPicture(String fileName)
//        {
//            EwsUtilities.ValidateMethodVersion(this.Service, ExchangeVersion.Exchange2010, "SetContactPicture");
//
//            InternalRemoveContactPicture();
//            FileAttachment fileAttachment = Attachments.AddFileAttachment(Path.GetFileName(fileName), fileName);
//            fileAttachment.IsContactPhoto = true;
//        }

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

  if (!this.PropertyBag.IsPropertyLoaded(ItemSchema.Attachments)) {
    throw new PropertyException(
        "AttachmentCollectionNotLoaded", "Attachments");
  }

  for (FileAttachment fileAttachment
      in this.Attachments as Iterable<FileAttachment>) {
    if (fileAttachment.IsContactPhoto!) {
      return fileAttachment;
    }
  }
  return null;
}