Wrong encoding when sending mails with HTML body using MS Graph API and Java SDK client
Hi,
I'm sending emails using the MS Graph API and the Java Graph SDK ( https://learn.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0&tabs=java ). However, I can't control the encoding used in the email body. It seems to sometimes randomly pick between "Windows-1252" or "iso-8859-1". This leads to garbled symbols in the email body.
For example, I'm setting the mail body in Java like so:
ItemBody body = new ItemBody();
body.contentType = BodyType.HTML;
body.content = "<p>Test Mail über Outlook365. öäü#+ß^°123§%&/()=?`´#'*~+-<>|,;.:-_\"áàúù\\{}[]âûôêéè</p>";
message.body = body;
The email body seems to be still encoding in UTF-8, but the wrong charset header displays many of the characters wrong in the email:
The encoding header in the HTML email body is "Windows-1252", which is wrong and should always be "utf-8".
I'm already setting the "-Dfile.encoding=UTF-8" start parameter and the return value of "Charset.defaultCharset()" is also UTF-8. Is there any way I can control the content encoding of mails send via the Graph API using the Java SDK client?
Btw, I'm having the same issues with content in events and cancellation messages that I create using the API.
Best regards,
Ben