我正在尝试实施电子邮件服务。我有一个存储库类,你可以看到:
ConfigRepository objConfigRepository = new ConfigRepository();
public bool SendMail(Message message, List<User> lstUser)
{
bool result = true;
try
{
foreach (User item in lstUser)
{
int reciverId = item.Id;
var ConfigMail = objConfigRepository.GetAll().First();
//var user = objUserRepository.FindBy(i => i.Id == reciverId).First();
WebMail.SmtpServer = ConfigMail.SmtpServer;
WebMail.SmtpPort = int.Parse(ConfigMail.SmtpPort);
WebMail.EnableSsl = ConfigMail.EnableSsl;
WebMail.UserName = ConfigMail.Username;
WebMail.Password = ConfigMail.Password;
WebMail.From = ConfigMail.From;
WebMail.Send(to: item.Email, subject: message.Title, body: message.MsgText);
}
}
catch (Exception ex)
{
result = false;
}
return result;
}
}
正如您所看到的,sendmail
需要2个参数message
和userinfo
。在我的控制器中,我将此方法称为:
objEmailRepository.SendMail(message, lstUser);
但我收到了这个错误:
Method not found: 'Void System.Web.Helpers.WebMail.Send(System.String, System.String, System.String, System.String, System.String, System.Collections.Generic.IEnumerable`1<System.String>, Boolean, System.Collections.Generic.IEnumerable`1<System.String>)'.
祝你好运
答案 0 :(得分:1)
System.MissingMethodException: Method not found?
尝试清理并重新编译您的解决方案,并确保您在GAC中拥有最新版本的dll