-2
protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                MailMessage message = new MailMessage(EmailTo.Text, Emailfrom.Text, EmailSubject.Text, EmailBody.Text);
                SmtpClient client = new SmtpClient("smtp.gmail.com",587);
                client.EnableSsl = true;
                client.Credentials = new System.Net.NetworkCredential("imranrizvi1992@gmail.com", "sihhhhjj");
                client.Send(message);
            }
            catch (Exception ex)
            {
                Label1.Text = ex.StackTrace;
            }

        }

I am sending the email via asp.net smtp but it throws some error which i dont know how to resolve this :

at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response) at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, MailAddress from, Boolean allowUnicode) at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message) at ProjectManagmentSystem.WebForm1.Button1_Click(Object sender, EventArgs e) in E:\ProjectManagmentSystem\ProjectManagmentSystem\Project.aspx.cs:line 73

mason
  • 31,774
  • 10
  • 77
  • 121
  • To solve this problem you need to click on the Link marked above. If you have not received email then use the following link https://www.google.com/settings/security/lesssecureapps – FullStackLoser Jul 21 '18 at 15:53
  • I have solved the problem by making turn on access to less secure apps in gmail .. – FullStackLoser Jul 21 '18 at 15:54
  • 1
    You're catching the stack trace from the exception, but not the actual error message. Which one do you think is likely to be more helpful in this scenario? – mason Jul 21 '18 at 16:59

1 Answers1

0

I have solved the problem by making turn on access to less secure apps in gmail

To solve this problem you need to click on the Link marked above. If you have not received email then use the following link google.com/settings/security/lesssecureapps –