利用.net自带的system.web.mail.net发邮件以前可以,现在突然不行了
代碼如下:
public void SendMail(string NextUserID, string NextUserName)
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress("[email protected]", "行政採購系統");//[email protected]
mail.To.Add(GetUserMail(NextUserID));//收件者(下一關處理人)
mail.Subject = "行政採購驗收單";
mail.IsBodyHtml = true;
mail.Body = GetMailBody(NextUserID, NextUserName);
SmtpClient mailSmtp = new SmtpClient();
mailSmtp.Host = "172.16.1.19";
mailSmtp.Port = 25;
mailSmtp.Credentials = new NetworkCredential("Bpmadmin", "1234569", "mamalove");
try
{
mailSmtp.Send(mail);//這理執行就報錯,以前(已經用一年多了)都是OK的...
Page.ClientScript.RegisterStartupScript(GetType(), "", "ReturnValues();", true);
}
catch (Exception ex)
{
Page.ClientScript.RegisterStartupScript(GetType(), "", "alert('本次操作成功,但郵件發送失敗,請你電話通知該單的下一關處理人 "+NextUserName+"');", true);
Page.ClientScript.RegisterStartupScript(GetType(), "", "ReturnValues();", true);
}
}
代碼如下:
public void SendMail(string NextUserID, string NextUserName)
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress("[email protected]", "行政採購系統");//[email protected]
mail.To.Add(GetUserMail(NextUserID));//收件者(下一關處理人)
mail.Subject = "行政採購驗收單";
mail.IsBodyHtml = true;
mail.Body = GetMailBody(NextUserID, NextUserName);
SmtpClient mailSmtp = new SmtpClient();
mailSmtp.Host = "172.16.1.19";
mailSmtp.Port = 25;
mailSmtp.Credentials = new NetworkCredential("Bpmadmin", "1234569", "mamalove");
try
{
mailSmtp.Send(mail);//這理執行就報錯,以前(已經用一年多了)都是OK的...
Page.ClientScript.RegisterStartupScript(GetType(), "", "ReturnValues();", true);
}
catch (Exception ex)
{
Page.ClientScript.RegisterStartupScript(GetType(), "", "alert('本次操作成功,但郵件發送失敗,請你電話通知該單的下一關處理人 "+NextUserName+"');", true);
Page.ClientScript.RegisterStartupScript(GetType(), "", "ReturnValues();", true);
}
}
不知道為什麼webform的不行(之前正常運行了一年多發郵件都是沒問題的webfrom)