We send calendar invites from our system in multiple languages. (English, Spanish, German etc) Recently we added Georgian and are having issue the the encoding of MailMessage.
For example 'თბილისი' in the email arrives as 'თბილისი'
The email we send includes a HTML AlternateView and a text/calendar AlternateView. I have both AlternateViews TransferEncoding set to QuotedPrintable.
It works correctly for the HTML view but not the calendar view. It always gets sent as 7bit.
In my SmtpClient
I have set DeliveryFormat = SmtpDeliveryFormat.International
This is how I add my AlternateView
:
var iCalInvite = InterviewService.CreateICALInvite(uniqueId, model.StartTimeUTC, model.EndTimeUTC, model.Location, model.Note, personCompany.Person.Email, personCompany.Person.FullName, interviewAttendee, model.Attendees, msg, _currentUser);
iCalInvite.TransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable;
msg.AlternateViews.Add(iCalInvite);
This is the output of the HTML View
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
This is the incorrect output of the calendar view
Content-Type: text/calendar; method=REQUEST; charset=UTF-8;
Content-Transfer-Encoding: 7bit
I've tried setting to the encoding of the MailMessage in a number of combinations but none seems to output the Georgian text correctly.
MailMessage msg = new MailMessage();
msg.BodyTransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable;
msg.BodyEncoding = Encoding.UTF8;
Any help of direction would be greatly appreciated. I've spent hours trying various combinations of encoding to no avail.
Thanks!
Here's an example of what appears in Gmail. The HTML view appears location appears correctly but the card doesn't.
It turns out it's nothing to do with my code above.
We use a 3rd party provider for sending emails (PostmarkApp). They convert all text/calendar attachments/alternative views to 7-bit before sending. As a result, non-ASCII characters will end up getting mangled.
I changed the SMTP details to Gmail and the email sent with the correct encoding. I have an open ticket with them regarding the issue.