且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用c#生成邮件时出现问题

更新时间:2022-10-18 15:03:54

尝试在服务器上配置证书

我在linux服务器上遇到同样的问题,之后我在终端写了这个:

certmgr -ssl smtps://smtp.gmail.com:465

mozroots --import --ask-remove

一切正常

I am using below code to generate mail through C # code

SmtpClient smtp = new SmtpClient("smtp.live.com", 587);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("XYZ@live.com", "********");
MailMessage mail = new MailMessage("XYZ@live.com", "ABC@live.com", "Registered Query", ("Dear Sir" + "\r\n " + "\r\n " + TextBox4.Text + "\r\n " + "\r\n " + TextBox1.Text + "\r\n" + TextBox3.Text + "\r\n" + TextBox2.Text));
smtp.Send(mail);
Response.Redirect("Submitbtn.aspx");


It was working properly offline when i running on my local computer,
But I uploading it on server after publishing website it is not working kindly help……………………

Try to configure certificates on server
I had the same problem on linux server, and after i wrote this in terminal:
certmgr -ssl smtps://smtp.gmail.com:465
mozroots --import --ask-remove
all worked fine