在asp.net中发送邮件 [英] sending mail in asp.net

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

问题描述

获取错误 SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应为:5.5.1需要身份验证。我的代码为

Error Geting The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. My code as

protected void Button1_Click(object sender, EventArgs e)
   {
       MailMessage mail = new MailMessage();
       SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
       mail.From = new MailAddress("mirajmishra1992@gmail.com");
       mail.To.Add(YourEmail.Text.ToString());
       mail.Subject = YourName.Text.ToString();
       mail.Body = Comments.Text.ToString();
       SmtpServer.Port = 587;
       SmtpServer.Credentials = new System.Net.NetworkCredential("RajnishMishra", "computer");
       SmtpServer.EnableSsl = true;
       SmtpServer.Send(mail);
      // MessageBox.Show("mail Send");
  }

推荐答案

http://www.codeproject.com/Answers/273383/sendind-mail-using-smtp-in -asp-net#answer2
http://www.codeproject.com/Answers/273383/sendind-mail-using-smtp-in-asp-net#answer2


解决方案:



a)通过此链接打击或谷歌搜索进入gmail安全中心 gmail secrity并使用您的Gmail帐户登录

https://accounts.google.com/ServiceLogin ?elo = 1



b)在安全/近期活动旁边,点击查看所有活动



c)你将能够看到异常活动,它将显示所有不寻常的活动事件,选择相关事件并通过点击是的,那就是我!来支持它。





//点击允许访问您的Google帐户



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


using (MailMessage mm = new MailMessage("from email", "To email")
               {

                   StreamReader reader = new StreamReader(System.Web.HttpContext.Current.Server.MapPath("~/HtmlPage.html"));
                   string readFile = reader.ReadToEnd();
                   string myString = "";
                   myString = readFile;
                   string fname=dttemp.Rows[0][1].ToString();
                   myString = myString.Replace("


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

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