指定的字符串不是电子邮件地址所需的格式。指定的字符串不是电子邮件地址所需的格式
return Email("SampleEmail", model);
我试图在有人向他注册电子邮件时自动发送电子邮件
这是代码
邮件控制器
public class MailController : MailerBase
{
public EmailResult SampleEmail(Users model)
{
From = "no-reply@mysite.com";
To.Add(model.Email);
Subject = "Welcome To Our Site ";
return Email("SampleEmail", model);
}
这是UserContoller
public ActionResult Create()
{
var user = new Users
{
UserName = "user.UserName",
Email = "user.Email"
};
new MailController().SampleEmail(user).DeliverAsync();
return View();
}