我有发送电子邮件代码:为什么电子邮件不在这里发送?
public static bool SendEmail(
string fromEmail, string toEmail,
string subject, string body,
bool isBodyHtml = false, bool isThrowException = false)
{
var message = new MailMessage(fromEmail, toEmail)
{
IsBodyHtml = isBodyHtml,
Subject = subject,
Body = body,
};
using (var client = new SmtpClient())
{
try
{
client.Send(message);
}
catch (Exception ex)
{
if (isThrowException)
{
throw new Exception(ex.ToString());
}
}
}
return true;
}
在web.config
我:
<system.net>
<mailSettings>
<smtp>
<network host="smtp.bizmail.yahoo.com" port="25" enableSsl="true" [email protected]" password="@cr123" defaultCredentials="true"/>
</smtp>
</mailSettings>
</system.net>
</configuration>
现在我没有任何异常,尚邮在另一端没有收到。 我可以通过我的凭据登录到yahoo.com。 仍然
client->credentils->domain=""
client->ServicePoint = 'client.ServicePoint' threw an exception of type 'System.TypeInitializationException'
它出了什么问题?
该代码运行良好...在1个月前,我没有更改一行,出了什么问题?
这是你真正的用户名和密码! –
没有更多 - 我只是删除它的情况下:P – BugFinder
其中''实际上位于配置? –