Whitespaces removed from plain text email messagebody
Hi,
my original - plain text - email looks like this:
Line 1
Line 2, followed by empty 3. line
Line 4, followed by empty 5. and 6. line
Line 7 with one leading space
Line 8 with two leading spaces
> line 9 with leading ">"
> line 10 with leading space + ">"
> line 11 with 2 leading spaces + ">", followed by 2 empty lines
Line 14 (last line)
What is received by ews-java-api - with BodyType.Text - is:
Line 1
Line 2, followed by empty 3. line
Line 4, followed by empty 5. and 6. line
Line 7 with one leading space
Line 8 with two leading spaces> line 9 with leading ">" > line 10 with leading space + ">" > line 11 with 2 leading spaces + ">", followed by 2 empty lines
Line 14 (last line)
After some investigation I found the problem is in MessageBody#readTextValueFromXml() and EwsXmlReader#read() were "unwanted" whitespace is always removed. I made some small changes in these two files to keep whitespaces for plain text messagebodys. Now plain text messages come out as expected.
If you are interested in my solution I can provide a patch file or make a fork & pull request. Just let me know.
superelchi
Please make a pull-request and link it to this issue
Agree that in this case the class is written more or less untestable. In general I like unit-tests for most of the changed code.
But another thing: could you possibly add some logging? The last day's I've been regretting logging too litle :-)
Well unit-testing is sure a good thing. And some more for ews-java-api could not hurt. ;) But as far as I can see, this would require some heavy refactoring to test classes like EWSServiceXmlReader, EWSService, etc.
Logging: yes - but what? The "raw" messagebody is already shown if trace is enabled with ExchangeService#setTraceEnabled() and the "converted" body is availabe in the received mail. Logging something like "Reading messagebody with type=Text - keeping wihtespace" / "Reading messagebody with type=HTML - removing whitespace" does - in my opinion - only generate noise in the logfile.
some debug logging about text vs html-body? info-logging should be kept to low-noise, but the being able to turn on some debug logging and getting the data out is great :-)
Okay. Added some logging to MessageBody.java with debug-level.