Windows应用程序的设置不会发送邮件 [英] Mail is not sent by setup of windows Application

查看:95
本文介绍了Windows应用程序的设置不会发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Experts,

我正在开发一个Windows应用程序。我正在通过表格上的按钮发送邮件。我运行我的应用程序时它工作正常。但如果我创建此应用程序的安装程序,那么它会给出错误。我如何解决它。请帮助



提前致谢.....

我得到的错误是



根据验证程序,远程证书 无效。





我的代码是

 mail.From =  new  MailAddress(  abc@gmail.com);  //  我的Gmail ID  
字符串 \\ temp = < span class =code-string> ;
mail.To.Add(txtemail.Text);
mail.Subject = 用户名确认&&密码;
StreamReader reader = new StreamReader( HTMLPage1热媒);
string readFile = reader.ReadToEnd();
string myString = readFile;
string date = System.DateTime.Now.Date.ToShortDateString();
string str = PopulateBodyEnquiry(txtCmp.Text,UserName,UserName,Pwd,date);
mail.Body = str;
mail.IsBodyHtml = true ;
SmtpClient smtp = new SmtpClient( smtp .gmail.com);
smtp.Port = 587 ;
smtp.Host = smtp.gmail.com;
smtp.EnableSsl = true ;
smtp.UseDefaultCredentials = false ;
smtp.Credentials = new System.Net.NetworkCredential( mygmailId password);
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback( delegate object sender2,X509Certificate证书,X509Chain链,SslPolicyErrors sslPolicyErrors)
{
return true ;
});
smtp.Send(mail);

解决方案

尝试重置您的Gmail帐户密码。您应该有一个强大的字母数字密码来发送电子邮件。



此外,您应该启用您的应用程序来访问Gmail帐户。

https://accounts.google.com/DisplayUnlockCaptcha [ ^ ]: - )


检查你的gmail帐户你已经把任何第二个变种代码放在gmail中请删除它..


我解决了通过myselft。当我设置这个我不包括具有邮件正文的Html文件。包括它后,它工作正常。感谢

Hello Experts,
I am working on a windows application. I am sending a mail trough gmail on a button at a form. it works fine when I run my application. but if I create Setup of this aapplication then it gives error. How i Solve it .Pls Help

Thanks in advance.....
The error which i got is

The remote certificate is invalid according to the validation procedure.



and my code is

mail.From = new MailAddress("abc@gmail.com");//My Gmail ID
                       string emp = "";
                       mail.To.Add(txtemail.Text);
                       mail.Subject = "Confirmations of User Name && Password";
                       StreamReader reader = new StreamReader("HTMLPage1.htm");
                       string readFile = reader.ReadToEnd();
                       string myString = readFile;
                       string date = System.DateTime.Now.Date.ToShortDateString();
                       string str = PopulateBodyEnquiry(txtCmp.Text, UserName, UserName, Pwd, date);
                       mail.Body = str;
                       mail.IsBodyHtml = true;
                       SmtpClient smtp = new SmtpClient("smtp.gmail.com");
                       smtp.Port = 587;
                       smtp.Host = "smtp.gmail.com";
                       smtp.EnableSsl = true;
                       smtp.UseDefaultCredentials = false;
                       smtp.Credentials = new System.Net.NetworkCredential("mygmailId", "password");
                       smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                       ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate(object sender2, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
                       {
                           return true;
                       });
                       smtp.Send(mail);

解决方案

Try resetting your gmail account password. You should have a strong alpha numeric password for sending email.

Also,you should enable your application to access gmail account.
https://accounts.google.com/DisplayUnlockCaptcha[^] :-)


check ur gmail account u have put any second varification code in gmail please remove it..


I solve by myselft. when i make setup of this i not include the Html file which have the mail body. After include this it works fine. thanks


这篇关于Windows应用程序的设置不会发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆