title: How I can get email headers programmatically from MS Exchange Server in Java?
body: <p>I can't get access to headers in email. At that moment I can get only ExtendedPropertyCollection object, but I don't know how to work with it.</p>
  
  <pre><code>ItemEvent item = (ItemEvent) event;
  EmailMessage message = EmailMessage.bind(args.getSubscription().getService(), item.getItemId());
  ExtendedPropertyCollection extendedProperties = ((ExtendedPropertyCollection) message.getExtendedProperties());
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>The result code in Java looks like:</p>
  
  <pre><code>PropertySet propertySet = new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.MimeContent);
  EmailMessage message = EmailMessage.bind(args.getSubscription().getService(), item.getItemId(), propertySet);
  String emailTextWithHeaders = new String(message.getMimeContent().getContent());
  </code></pre>