Contact us page RRS feed

  • Question

  • Dear sir,

    Kindly help me. I have a contact us page asp.net there have 4 textboxes and a submit button. when user submit the button i need to send the textbox datas to my gmail account. Can you help me. i got following error.

    The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at

    I used  following code but its not work.

            MailMessage msg = new MailMessage();
            msg.From = new MailAddress("aspectind@gmail.com");
            msg.Subject = txtsubject.Text;

            msg.Body="<b>Sender name:</b>"+txtname.Text+"<br/>"
                + "<b>Sender E-mail:</b>" + txtemail.Text + "<br/>"
                + "<b>Comments:</b>" + txtcomments.Text;

            msg.IsBodyHtml = true;

            SmtpClient smtpclient = new SmtpClient("smtp.gmail.com",587);
            smtpclient.EnableSsl = true;
            smtpclient.Credentials = new System.Net.NetworkCredential("aspectind@gmail.com","15171819");

            Label5.Text = "Thank you for contacting us";

    Thanks & Regards 



    Sunday, June 17, 2018 12:27 PM

All replies

  • Kindly help me.


    Sunday, June 17, 2018 1:12 PM
  • See the following answer along with the reply mark with 70 points in regards to setup for the gmail account. You get the code right but if the account is not setup that can cause issues too.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Proposed as answer by Dolen Zhang Wednesday, June 20, 2018 1:07 AM
    Sunday, June 17, 2018 3:10 PM