ASP.NET 4.5 Setting SMTP Encoding in Config

384 views Asked by At

I am working on a website I didn't write so I don't know it inside out. The default setting for SMTP mail encoding is being set to ASCII (somewhere) but I want it to be UTF-8. It seems this should be in a config file but I can't find where it is specified. I'm aware that I can manually set it in the code but I want the change to be site wide. The emails are in html. Everywhere else on the site except for email seem to be correctly set to UTF-8.

Currently, my email headers have this setting for encoding:

    Content-Type: text/html; charset=us-ascii

And it should be:

    Content-Type: text/html; charset=UTF-8

or something to that effect.

Here is some sample code that is used. I don't think it is that informative. The email values are being produced in another class. This is the part that sends the email.

        using System.Net.Mail;
        ....
        MailMessage msg = new MailMessage();
        msg.IsBodyHtml = true;
        msg.From = new MailAddress(shopEmail, (Globals.Settings.Shop.MailName));
        // This just pulls these values from another class
        msg.Subject = editEmailTemplates.EmailSubject;
        msg.Body = editEmailTemplates.EmailBody;
        SmtpClient mailClient = new SmtpClient();
        try
        {
            mailClient.Send(msg);
        }
        catch(SmtpException)
        {
        }
0

There are 0 answers