MailMessage.Encrypt, problems with german umlauts like äöü

0 votes
asked Jun 11 by AlexG (150 points)
edited Jun 11 by AlexG

Hello,

we use Rebex Secure Mail to send encrypted html emails. If the email contains german umlauts (like äöü), they will not be displayed correctly in OWA (Outlook Web Access).

The encoding ist set to utf-8, the html body is:

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title></title>
  </head>
  <body>
    <h2>HTML mail with german umlauts</h2>
    <div>äöüßÄÜÖ</div>
    <br/>
    <span>Mit freundlichen Grüßen</span>
  </body>
</html>

The following picture shows the difference between Outlook and OWA:

Mail

Some example how we create an send the email:

var mimeMessage = new MailMessage();
mimeMessage.BodyHtml = "some html text";
mimeMessage.DefaultCharset = System.Text.Encoding.UTF8;
mimeMessage.Encrypt(receiverCertificates);

Smtp.Send(mimeMessage, config);

So my question:
Did we forget something or is this a bug in Outlook Web Access ?

1 Answer

+1 vote
answered Jun 11 by Lukas Pokorny (124,570 points)
selected Jun 15 by AlexG
 
Best answer

I guess that a problem in the e-mail message such as a mismatch between MIME entity's charset and HTML charset is more likely to be a cause than a bug in Outlook Web Access. How do you actually construct the message? Do you assign the HTML text via MailMessage.BodyHtml, or via MailMessage.Views?

One random tip that might help - try setting the default charset to UTF-8:

var mail = new MailMessage();
mail.DefaultCharset = System.Text.Encoding.UTF8;
mail.BodyHtml = "some html text";
mail.Encrypt(...);
commented Jun 11 by AlexG (150 points)
Thank you for your response. Ive updated my question with an example how we create an send the email.
commented Jun 11 by Lukas Pokorny (124,570 points)
Does this problem occur with unencrypted messages as well, if they are otherwise constructed in the same way, just without the Encrypt method call?
commented Jun 11 by AlexG (150 points)
The problem does not occur if i comment out the Encrypt method call.
commented Jun 11 by Lukas Pokorny (124,570 points)
Thanks! In that case, it looks like either there is a bug related to the Encrypt method, or it's really a server-side issue. We'll look into this!
commented Jun 15 by Lukas Pokorny (124,570 points)
The DefaultCharset property must be assigned before BodyHtml/BodyText, so please try swapping them:

var mimeMessage = new MailMessage();
mimeMessage.DefaultCharset = System.Text.Encoding.UTF8;
mimeMessage.BodyHtml = "some html text";
mimeMessage.Encrypt(receiverCertificates);

Smtp.Send(mimeMessage, config);
commented Jun 15 by AlexG (150 points)
This solves the problem.

Thanks for the support
...