I am trying to send a confirmation email when a user registers together with the generated Token. Token is OK. But when sending email,I am getting this error:
System.NotSupportedException: Store does not implement IUserEmailStore<TUser>.
And my code inside AccountController in the Register method looks like this: It is the SendEmailAsync() method which is causing the error:
if (result.Succeeded)
{
var 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 this link: <a href=\"" + callbackUrl + "\">link</a>");
ViewBag.Link = callbackUrl;
return View("DisplayEmail");
}
In my IdentityConfig.cs file, I have a class:
public class ApplicationUserManager : UserManager<ApplicationUser>
{
public ApplicationUserManager(IUserStore<ApplicationUser> store)
: base(store)
{
}
}
Also inside my IdentityConfig.cs file, I have another class:
public class EmailService : IIdentityMessageService
{
public Task SendAsync(IdentityMessage message)
{
// Plug in your email service here to send an email.
SmtpClient client = new SmtpClient();
return client.SendMailAsync(ConfigurationManager.AppSettings["TranscriptEmailAddr"],
message.Destination,
message.Subject,
message.Body);
}
}
Please assist.