Search code examples
asp.net-mvcemailmvcmailer

MvcMailer russian charset in Body problem


I have MVCMailer installed at my app. But When i sent the mail with russian charset body i get something like this:

Ïðèâåòñòâóåì Âàñ íà ñàéòå

Good looking, isnt it? :)

For detailed info, can show IUserMailer.cs:

namespace photostorage.Mailers
{ 
    public interface IUserMailer
    {
        MailMessage Welcome(string userMail, string login, string password);
        MailMessage PasswordReset();
    }
}

And UserMailer.cs:

       public virtual MailMessage Welcome(string userMail, string login, string password)
        {
            var mailMessage = new MailMessage{Subject = "Добро пожаловать на FotoStorage.org"};

            mailMessage.To.Add(userMail);
            ViewBag.login = login;
            ViewBag.password = password;
            PopulateBody(mailMessage, viewName: "Welcome");

            return mailMessage;
        }

_Layout.cshtml:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    </head>
    <body>
        @RenderBody()
    </body>
</html>

And Welcome.cshtml

<div>
    <div><h1>Приветствуем Вас на сайте ......</h1></div>
    <div>
        <p>
            Ваш логин: @ViewBag.login
            Ваш пароль: @ViewBag.password
        </p>
        <p>
            Постоянная ссылка на Ваши фото - .......
        </p>
    </div>
</div>

Thanks a lot! :)


Solution

  • Make sure that your template is saved as UTF8 (which should be the default for new files).