Quantcast
Channel: Sending email error - SMTP Server requires a secure connection 5.5.1
Viewing all articles
Browse latest Browse all 11

Re: Sending email error - SMTP Server requires a secure connection 5.5.1

$
0
0

This is my code (added the above line) but still getting same error:

protected void Button1_Click(object sender, EventArgs e)
    {
        // Create a message and set up the recipients.
        SmtpClient smtpClient = new SmtpClient();
        MailMessage message = new MailMessage();
        message.To.Add("mymail@domain.com");
        message.Subject = "Form - ";
        message.IsBodyHtml = true;
        message.Priority = MailPriority.High;
        message.Body = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
        message.Body += "<HTML><HEAD><META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\">";
        message.Body += "</HEAD><BODY>";

        message.Body += "<table border='1'><tr><td>Textbox1.Text</td><td>Textbox2.Text</td></tr><tr><td>Textbox3.Text</td><td>Textbox4.Text</td></tr></table>";
        message.Body += "</BODY></HTML>";

               // Send the message.
        smtpClient.Port = 587;
        smtpClient.UseDefaultCredentials = false;
        smtpClient.Credentials = new System.Net.NetworkCredential("mygmailusername@gmail.com", "password");
        smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;

        smtpClient.EnableSsl = true;

        smtpClient.Send(message);
        EmailSentForm.Visible = Visible;
}




Viewing all articles
Browse latest Browse all 11

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>