Using the default mvc code for confirming email addresses on registration but when the email gets sent it isn't showing the html.
Template MVC code:
string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" +
callbackUrl + "\">here</a>");
Send Email Async:
public Task SendAsync(IdentityMessage message)
{
// Plug in your email service here to send an email.
SmtpClient client = new SmtpClient();
return client.SendMailAsync("email here",
message.Destination,
message.Subject,
message.Body);
return Task.FromResult(0);
}
When looking through some of the other questions on SO, I changed my send code slightly so that I could set the body to allow html but I still have the same issue
public Task SendAsync(IdentityMessage message)
{
MailMessage msg = new MailMessage();
msg.IsBodyHtml = true;
msg.Body = message.Body;
// Plug in your email service here to send an email.
SmtpClient client = new SmtpClient();
return client.SendMailAsync("email here",
message.Destination,
message.Subject,
msg.Body);
return Task.FromResult(0);
}
Any ideas as to why this is happening?
TIA
await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking here: " + callbackUrl). In the last code sample, try usingreturn client.SendMailAsync(msg)instead of using old pattern.