Local characters in e-mail subject

MortenSteengaard
Member Posts: 144
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', 'my-email@gmail.dk', 'my-email@gmail.dk', '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
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', 'my-email@gmail.dk', 'my-email@gmail.dk', '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
0
Best Answer
-
It sounds like your PDF file is in some weird encoding. If I copy paste you code it works fine with danish characters
For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.0
Answers
-
I think than those characters aren't in utf-8, you should use another iso enconding instead. Google says than danish one is ISO 3166 o ISO 639.0
-
The e-mail that works has a header with a charset = UTF-8, so that must be ok.
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.0 -
I couldn't find those characters there https://en.wikipedia.org/wiki/UTF-8
So on, the subject it's a text, I don't get why do you related that with the attachment0 -
It sounds like your PDF file is in some weird encoding. If I copy paste you code it works fine with danish characters
For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.0 -
Hi both,
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,
Morten0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions