-1

I am trying to send email using Asp.net using my account....
I want to send it on a gmail account say "abc@gmail.com"
but it gives ERROR..
ErrorServer does not support secure connections.

the code is below:

try
{
  //Create Mail Message Object with content that you want to send with mail.
            System.Net.Mail.MailMessage MyMailMessage = new System.Net.Mail.MailMessage("abc@yahoo.co.in","xyz@gmail.com",
        "This is the mail subject", "Just wanted to say Hello ");

            MyMailMessage.IsBodyHtml = false;

      System.Net.NetworkCredential mailAuthentication = new
  System.Net.NetworkCredential("abc@yahoo.co.in", "123");

   System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtp.mail.yahoo.com", 587);

            //Enable SSL
            mailClient.EnableSsl = true;
            mailClient.UseDefaultCredentials = false;
            mailClient.Credentials = mailAuthentication;
         
         mailClient.Send(MyMailMessage);
            this.TextBox1.Text = "SUccess";
        }
        catch(Exception ex)
        {
            this.TextBox1.Text = "Error" + ex.Message ;
        
        }

Any ideas ???

Votes + Comments
You should know about code tags by now.
3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Yaseen Hejazi
0

mailClient.Port = 587;
mailClient.EnableSsl = true;
mailsmtpClient.UseDefaultCredentials = false;
mailClient.DeliveryMethod = SmtpDeliveryMethod.Network;


I was facing same issue and fixed by adding above lines.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.