How can i get the body text as plain text from exchange server

0 votes
asked Oct 18, 2016 by andreas (160 points)

I am using following c# code to get an e-mail from exchange

var messageInfo = client.GetMessageInfo(item.Id, EwsItemFields.Envelope | EwsItemFields.Body);
var text = messageInfo.Body.Content;

Because of security reasons i always need the body content as text an not as html.

When using EWS (Microsoft) i can define a PropertySet and set the RequestBodyType as follows

ps.RequestedBodyType = BodyType.Text

How can i do this with Rebex Ews

Applies to: Rebex Secure Mail

2 Answers

+1 vote
answered Oct 20, 2016 by Pavel Matyska (15,060 points)
selected Oct 21, 2016 by andreas
Best answer

Thank you for the info. It turned out that adding support for downloading plain text body of a message (if the message contains it) for all Exchange server versions is easy enough to add. Here is a link to a trial version of a beta build. (I sent a link to full version of this beta to your email.)

The beta build contains new EwsItemFields.TextBody enum value that makes it possible to download plain text body of a message the same way as EwsItemFields.Body does. The value (if it is returned by the server) is stored in EwsMessageInfo.TextBody property.

0 votes
answered Oct 19, 2016 by Pavel Matyska (15,060 points)


Specifying plain text to be retrieved is not supported yet, but it should not be hard to add. Actually, we did some testing and find out that different exchange servers needs different request to get plain text message body. Can you please tell which exchange server version are you communicating with? For example, Exchange 2010 with service pack 2 is enough. With this information, we can add support for your version and build you custom beta and add support for other Exchange servers later.

commented Oct 20, 2016 by andreas (160 points)
The software communicates to Exchange 2010 SP3.