Hi experts,
I use Business Central version 13 on-prem.
I have made a new codeunit that uses codeunit "SMTP Mail" to send an e-mail. It works fine (also with Danish characters in the e-mail subject and body).
But if I add an attachment (a pdf-file), the Danish characters in the e-mail subject, is shown wrongly in Outlook.
The header of the e-mail has this, when it works:
Subject: Løn: Test mail
Content-Type: text/plain; charset="utf-8"
and this, when it does not work:
Subject: Løn: Test mail
Content-Type: multipart/mixed;
boundary="--boundary_28_3eeb0768-ce3e-47ce-810a-b3510541816c"
The subject of the e-mail with the attachment is shown as "Løn: Test mail".
Here is my codeunit:
SMTP.CreateMessage('From me', '
[email protected]', '
[email protected]', 'Løn: Test mail', 'The body', false);
SMTP.AddAttachment('C:\\temp\\Some-real-file.pdf','The-filename-to-show-in-the-mail.pdf');
SMTP.TrySend;
If I outcomment AddAttachment, everything works fine. If I add the attachment, the DotNet "Mail" object in codeunit "SMTP Mail" forgets that it is in Denmark.
Hope you can help.
Morten
Answers
But that is not the problem. The problem is that I cannot set the encoding anywhere. It is automatically set to UTF-8 (which works) and if I add an attachment to the e-mail, the encoding has changed to something that does not work.
So on, the subject it's a text, I don't get why do you related that with the attachment
Thank you for your reply. The test from SanderDk helped a lot.
The problem is solved. The mail server was set up in a wrong way and everything works fine now, as we use another server.
Best regards,
Morten