I'm using EWS Java API 1.2 to get e-mails from server. And I have a problem: I use properties like this:
PropertySet itemPropertySet = new PropertySet(BasePropertySet.FirstClassProperties);
itemPropertySet.setRequestedBodyType(BodyType.Text);
...
String body = message.getBody().toString();
In this example I get body as plain text. But I need to save formatting of body (e.g. empty lines). When I use BodyType.HTML I get all html tags, css styles etc. What is the best way to get body of message with saving formatting and excluding html tags, css styles, etc. Thank you for your replies!
Update with my solution: I've stopped on this variant. My problem was in empty lines, so now I handle BR and P tags by next functions:
public void handleStartTag(Tag t, MutableAttributeSet a, int pos) //To handle Tag.BODY
public void handleSimpleTag(Tag t, MutableAttributeSet a, int pos) //To handle Tag.BR and adding '\n'
public void handleEndTag(Tag t, int pos) //To handle Tag.P (and adding '\n') and Tag.BODY
public void handleText(char[] data, int pos)