I'm trying to send Email for my app and i have "è" and "é" character in my email subject that need to be send (It's important to be with the accent)
My vérification email is working "Bière - Vérification du email" and i receive it like that in my outlook.
Now when i send my Forgot Password email "Bière - Changement de mot de passe", i receive Bi??re - Changement de mot de passe"
I found those line to encode my string, but it didn't do anything and i get the same display error.
private static string GetIsoString(string str)
{
byte[] isobytes = Encoding.GetEncoding("ISO-8859-1").GetBytes(str);
byte[] ubytes = Encoding.Convert(Encoding.GetEncoding("ISO-8859-1"), Encoding.Unicode, isobytes);
return Encoding.Unicode.GetString(ubytes, 0, ubytes.Length);
}
My MailMessage:
return new MailMessage(_from, to)
{
Subject = subject,
Body = body,
// Tried Encoding.Unicode, UT8, UTF32
SubjectEncoding = Encoding.GetEncoding("ISO-8859-1"),
IsBodyHtml = true
};
How can i send my subject with accent without it to be converted to ??
EDIT
// this is my solution... i don't really understand why does it make it work... but tested few times and now i get my accent all the time!
HeadersEncoding = Encoding.UTF8,