有没有办法将SendEmailAsync设置为isHtml = true?

时间:2017-12-01 13:06:34

标签: asp.net-mvc email sendasync

我正在研究Asp.Net MVC中的忘记密码功能。

我能够成功发送忘记密码链接到电子邮件至SendEmailAsync方法,但电子邮件是isHtml = false。

我怎样才能做到这一点?

public Task SendAsync(IdentityMessage message)
{
   SmtpClient client = new SmtpClient();
   return client.SendMailAsync("email",
                                    message.Destination,
                                    message.Subject,
                                    message.Body);
}

1 个答案:

答案 0 :(得分:1)

您需要使用带有another overload对象的MailMessage。例如:

SmtpClient client = new SmtpClient();
var message = new MailMessage();
message.IsBodyHtml = true;
message.Body = "email";
//Set other properties such as subject etc.
return client.SendMailAsync(message);