登录和发送邮件时出错... [英] Error On Login And Send Mail ...
本文介绍了登录和发送邮件时出错...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我登录并尝试发送邮件..
当我运行此代码时,它显示以下错误:
服务器不支持安全连接。
错误来自Smtp.Send(Ml):
When I Login And Try To Send Mail..
When I run this code it shows the following error:
"Server Does Not Support Secure Connections."
The error comes on "Smtp.Send(Ml)":
protected void btnSend_Click(object sender, EventArgs e)
{
MailMessage ml = new MailMessage();
ml.From = new MailAddress(Session["EmailId"].ToString().Trim());
ml.To.Add(txtEmaillTo.Text);
ml.Subject = txtSubject.Text;
string Bd = txtMessageBody.Text;
ml.Body = Bd;
ml.IsBodyHtml = true;
if (FileUpload1.HasFile)
{
ml.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
}
SmtpClient smtpcode = new SmtpClient();
smtpcode.Host = "10.10.10.248";
smtpcode.Port = 25;
smtpcode.UseDefaultCredentials = false;
smtpcode.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtpcode.Credentials = new System.Net.NetworkCredential(Session["EmailId"].ToString().Trim(), Session["Password"].ToString().Trim());
smtpcode.Timeout = 20000;
smtpcode.EnableSsl = true;
smtpcode.Send(ml);
lblmessage.Visible = true;
lblmessage.ForeColor = Color.Green;
lblmessage.Text = "Message send successfully";
}
推荐答案
尝试下面的事情。
smtpcode .EnableSsl = false;
try below things.
smtpcode.EnableSsl = false;
这篇关于登录和发送邮件时出错...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文