3

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,
Vince
  • 1,279
  • 2
  • 20
  • 40
  • Isn't UTF8 default encoding? – Allen King Jun 06 '17 at 04:14
  • Yes, but if i don't put this line... something happen behind and change it or ... i don't really understand because this line is the solution... i didn't change anything else... very strange to me too... – Vince Jun 06 '17 at 16:27
  • 2
    I experienced the same problem,. IsBodyHtml set to true, default encoding is UTF8 but without explicit declaration of 'BodyEncoding = Encoding.UTF8;' accented characters do not display properly. – OverMars May 31 '18 at 20:44

0 Answers0