The question is therefore: What should we do so that all Swedish characters are supported and displayed correctly in all our mails?
Also has a thought, all mail are sent from our SMTP address with the consumer's e-mail as the sender, may this create problems for us?
The mail arrives to the customer and consumer, but in some cases the character encoding errors. We have tried to add this in ConfirmAppointment method, without success.
We also tried this to remove: From: =? Utf-8? Q? Eker = C3 = B6v = C3 = A4gen_82 by adding Encoding.
x.From = new MailAddress(setting.se_online_email, string.Format("{0} / {1}", customer.SalonName, model.LocationName), Encoding.GetEncoding("ISO-8859-1"));
This is an example of how an email might look like:
Static text entered in the email template is marked underline.
Från: =?utf-8?Q?Eker=C3=B6v=C3=A4gen_82 Skickat: den 2 januari 2013 19:14 Till: Itsperfect (bokning@itsperfect.se) Ämne: Bekräftelse - Bokat tid hos Hairligt på itsperfectö lördag den 5 januari 2013
Hej Stefan Karlsson,
Vi är glada för att du bokat tid hos oss pÃ¥ Härligt på itsperfectö.
Nedan följer information om din bokning:
Avbokning sker via telefon. Ej avbokad tid debiteras.
Vi skickar regelbundet ut nyhetsbrev till våra kunder.
Stefan Karls...
Member
3 Points
21 Posts
MvcMailer Ecoding problem (Swedish)
Jan 21, 2013 07:51 AM|LINK
Hello,
We use MVC .NET4 to create an application.
We have encountered an email encoding problem when we try to send mail to our customers.
The problem we have is that our static text entered into the .cshtml file. Not able åäö.
The file is saved with UTF-8 character encoding.
There are also problems in the email header, from address looks like this sometimes:
From: =? utf-8? Q? Eker = C3 = B6v = C3 = A4gen_82
The question is therefore:
What should we do so that all Swedish characters are supported and displayed correctly in all our mails?
Also has a thought, all mail are sent from our SMTP address with the consumer's e-mail as the sender, may this create problems for us?
Thanks in advance!
/ Sincerely
Stefan
Here is the code for the email method:
public virtual MvcMailMessage ConfirmAppointment(BookingViewModel model, Setting setting, CustomPrincipal customer) { model.Information = setting.se_online_message; model.SalonName = customer.SalonName; ViewData.Model = model; return Populate(x => { x.Subject = string.Format("Bekräftelse - Bokat tid hos {0} {1}", setting.se_online_name, model.StartDate.Value.ToString("dddd 'den' d MMMM yyyy")); x.ViewName = "ConfirmAppointment"; x.To.Add(customer.UserName); if (setting.se_online_email_copy != null && setting.se_online_email_copy == true) { x.Bcc.Add(setting.se_online_email); } x.Attachments.Add(CreateCalendarAppointment(model)); x.From = new MailAddress(setting.se_online_email, string.Format("{0} / {1}", customer.SalonName, model.LocationName)); }); }What we have tried to do:
The mail arrives to the customer and consumer, but in some cases the character encoding errors. We have tried to add this in ConfirmAppointment method, without success.
x.BodyEncoding = Encoding.GetEncoding("ISO-8859-1"); x.HeadersEncoding = Encoding.GetEncoding("ISO-8859-1");We also tried this to remove: From: =? Utf-8? Q? Eker = C3 = B6v = C3 = A4gen_82 by adding Encoding.
x.From = new MailAddress(setting.se_online_email, string.Format("{0} / {1}", customer.SalonName, model.LocationName), Encoding.GetEncoding("ISO-8859-1"));This is an example of how an email might look like:
Static text entered in the email template is marked underline.
Från: =?utf-8?Q?Eker=C3=B6v=C3=A4gen_82
Skickat: den 2 januari 2013 19:14
Till: Itsperfect (bokning@itsperfect.se)
Ämne: Bekräftelse - Bokat tid hos Hairligt på itsperfectö lördag den 5 januari 2013
Hej Stefan Karlsson,
Vi är glada för att du bokat tid hos oss pÃ¥ Härligt på itsperfectö.
Nedan följer information om din bokning:
Avbokning sker via telefon. Ej avbokad tid debiteras.
Vi skickar regelbundet ut nyhetsbrev till våra kunder.
DENNA BOKNING ÃR GJORD PÃ:
Kista
Finlandsgatan. 16, 164 74 Kista
BOKAD TID
lördag den 5 januari 2013 klockan:11:15
HOS VEM
Kenneth
BEHANDLING(AR)
Herrklippning (60 Minuter)