protected void btnSend_Click(object sender, EventArgs e)
{
string mFrom = "xxx.com";
string mTo = "yyy.com";
string msub="TESTSUBJECT";
string mMsg="TEST msg";
string mCc = "Test cc";
// User credential used for sending mail
string EmailSender = "xxx.com";
string EmailSenderPasswd = "zzz";
System.Net.NetworkCredential myCachet = new System.Net.NetworkCredential(EmailSender, EmailSenderPasswd);
SmtpClient smtp = new SmtpClient("smtpout.secureserver.net", 12234);
smtp.Credentials = myCachet;
MailMessage message = new MailMessage(mFrom.ToString(), mTo.ToString());
message.Subject = msub.ToString();
message.Body = mMsg.ToString();
message.IsBodyHtml = true;
if (mCc.Trim() != String.Empty)
{
message.CC.Add(new MailAddress(mCc.ToString()));
}
smtp.Send(message);
message.Dispose();
}
如果我传递了错误的密码,smtp.send(message) 方法会返回“消息失败”。但是,如果我传递了错误的电子邮件地址,它会作为“消息成功”的成功消息返回,即使我尝试尝试捕获异常,它也不会提供任何异常。如何知道该消息已成功传递?如果该消息未成功传递,则意味着它应该抛出未传递的消息,例如 gmail(消息传递失败)。帮我。