本文介绍了在asp.net中发送邮件代码的req的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里我收到的错误就像发送邮件一样....

这里网络连接也可用...

请回复我


 private void MailSend()
{
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient(smtp.gmail.com);
SmtpServer.Host =smtp.gmail.com;

mail.From = new MailAddress([email protected]);
mail.To.Add([email protected]);
mail.Subject =测试邮件;
mail.Body =这是用于测试来自GMAIL的SMTP邮件;

SmtpServer.Port = 587;

SmtpServer.Credentials = new System.Net.NetworkCredential([email protected],123456); //用户邮件名称和邮件密码
SmtpServer.EnableSsl = true;

SmtpServer.Send(mail);
}
catch(exception ex)
{
MessageBox.Show(ex.ToString());
}
}



或获得多种选择 []

here i am getting error like failure to send mail....
here network connection is also avaliable...
plz respond me

解决方案
Try this;

private void MailSend()
        {
            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");  
                SmtpServer.Host = "smtp.gmail.com";
 
                mail.From = new MailAddress("[email protected]");
                mail.To.Add("[email protected]");
                mail.Subject = "Test Mail";
                mail.Body = "This is for testing SMTP mail from GMAIL";
 
                SmtpServer.Port = 587;
 
                SmtpServer.Credentials = new System.Net.NetworkCredential("[email protected]", "123456"); // User Mail Name And Mail Password
                SmtpServer.EnableSsl = true;
 
                SmtpServer.Send(mail);              
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }


Or get many alternatives here[^]


这篇关于在asp.net中发送邮件代码的req的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 11:04