1

I tried to expand the 'from' field of my email, the code looks something like this:

name = 'Hans Müller';
mail = strcat(name, '<h.mueller@test.org>');
setpref('Internet','E_mail',mail);    
setpref('Internet','SMTP_Server','mail');
sendmail('input@test.org','New post',body);

That actually worked really well, but instead of the umlauts in the name of sender can see in outlook a black diamond - "M�ller" . I tried to change the default charset with

setpref ('Internet', 'E_mail_Charset', 'utf-8')

and

setpref ('Internet', 'E_mail_Charset', 'iso-8859-1')

Both variants were unsuccessful, the charset 'iso-8859-1' spoiled the umlauts in the body, which used to look normal.

Does anyone have any idea how to solve the problem? As I said, the body HTML text is absolutely fine, only the name of sender is not displayed correctly. Thanks in advance.

Melenkurion
  • 49
  • 1
  • 4
  • Are you sure this is not a Outlook problem? MATLAB seems to handle the umlaut well. – Ander Biguri Jan 22 '21 at 13:16
  • 1
    I think that the settings in outlook are OK - under incoming emails are the senders with umlaut in their names and they are displayed correctly. – Melenkurion Jan 22 '21 at 14:41
  • The From address in email is encoded in the email headers, not the email body, and I think email headers only support ASCII or Latin-1 values. There's probably some special encoding mechanism for it, and Matlab probably isn't aware of it, so your unicode "ü" is probably getting busticated when being transformed to an ASCII email header. I'll look in to this if I have time. Also, this is worthy of opening a ticket with Matlab Tech Support at support@mathworks.com. – Andrew Janke Jan 22 '21 at 22:07
  • See https://stackoverflow.com/questions/760150/can-an-email-address-contain-international-non-english-characters and https://tools.ietf.org/html/rfc6532. Matlab probably isn't on top of these things, because that's not their style. – Andrew Janke Jan 22 '21 at 22:09
  • BTW, you mean "Unicode", not "UTF8" here – Matlab stores its strings internally in UTF-16, not UTF-8, and transcoding has to happen when it converts its UTF-16 data to email headers or body text. – Andrew Janke Jan 22 '21 at 22:10

1 Answers1

0

I found an absolutely not elegant solution, and that is

regexprep(name,{'Ä','Ö','Ü','ä','ö','ü','ß'},{'Ä','Ö','Ü','ä','ö','ü','ß'})

That solved my problem.

Melenkurion
  • 49
  • 1
  • 4