0

I want to receive a message body text in plain text format. I am using the following code but when I am trying to get through extended property collection it gives nothing.

extendedPropertyDefinition = new ExtendedPropertyDefinition(0X1000,
                MapiPropertyType.String);

propertySet = new PropertySet(PropertySet.FirstClassProperties.getBasePropertySet(),
                ItemSchema.MimeContent, extendedPropertyDefinition);

propertySet.setRequestedBodyType(BodyType.HTML);


emailMessage = EmailMessage.bind(service, itemId, propertySet);
MadDev
  • 1,130
  • 1
  • 13
  • 29

1 Answers1

0

If you want the Plain body text then just make

propertySet.setRequestedBodyType(BodyType.HTML);

like

propertySet.setRequestedBodyType(BodyType.Text);

You can't request Both body types in the same request EWS will only even deliver one back to you. If you want both in the same request you can try to parse it out of the MimeContent but whether you will get both here will depend on the original format of the message. A lot of the times when ask for the Text body the Exchange Store does an one the fly conversion from whatever native format the message was sent in.

Glen Scales
  • 20,495
  • 1
  • 20
  • 23
  • I want both HTML and plain text content. If I try the below code :- PR_HTML_BODY= new ExtendedPropertyDefinition(0X1013, MapiPropertyType.Binary); propertySet = new PropertySet(PropertySet.FirstClassProperties.getBasePropertySet(), ItemSchema.MimeContent, PR_HTML_BODY); propertySet.setRequestedBodyType(BodyType.Text); this gives html as byte[] while converting this byte[] into String it produces junk for special characters. Is there anyway to get plain text through ExtendedPropertyDefinition – prabal shrivastava Mar 07 '17 at 06:48
  • You can't request both Message bodies in the same request (even if you use extended properties) it won't work for reasons i mentioned, you will need to make two request. You don't need to be using the extended properties in that case just use the strongly typed one and you won't get the issues because it will return the string. – Glen Scales Mar 07 '17 at 22:25