我有發送電子郵件代碼:爲什麼電子郵件不在這裏發送?
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
其中''實際上位於配置? –