NET中Windows应用程序中的邮件发送 [英] mailing in windows application in .net
本文介绍了NET中Windows应用程序中的邮件发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用c#.net开发一个Win应用程序.在这种情况下,我需要邮寄随机生成的密码哟用户.
为此,我正在使用此代码.
Hi ,
I am developing one win app using c#.net. In that i need to mail random generated password yo user.
for that i am using this code.
MailMessage mailObj = new MailMessage("fromaddress", "toaddress", "New Password", "your new password is " + strPassword);
SmtpClient SMTPServer = new SmtpClient("smtp.gmail.com");
SMTPServer.EnableSsl = true;
SMTPServer.Credentials = new System.Net.NetworkCredential("username", "password");
try
{
SMTPServer.Send(mailObj);
}
catch (Exception ex)
{
MessageBox.Show("error while sending mail");
}
但我得到这样的错误.
服务器不支持安全连接.
but i am getting error like this.
Server does not support secure connections.
can any one help me to resolve this.
推荐答案
smtp.google.com
要求您在使用SSL时在端口587
上进行连接.
添加以下行:
smtp.google.com
requires you to connect on port587
when using SSL.
Add the following line :
SMTPServer.Port = 587;
这篇关于NET中Windows应用程序中的邮件发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文