Rahul M

Rahul M

  • NA
  • 7
  • 0

Error in sending mail

Aug 8 2009 3:49 AM
 I have done a program to send email using yahoo smtp but it is showing an exception "failed to send mail"
following is the code
friends pls help

   try
            {
          
                MailMessage objMsg = new MailMessage();
                objMsg.To.Add(new MailAddress("address"));
                objMsg.From = new MailAddress("address");
               
                objMsg.Subject = "subject";
                objMsg.Body = "test mail";
               
                SmtpClient sc = new SmtpClient();
                sc.Host = "smtp.mail.yahoo.com";
                sc.Port = 465;
                sc.Credentials = new NetworkCredential("address", "password");
                sc.EnableSsl = false;
                sc.DeliveryMethod = SmtpDeliveryMethod.Network;
                sc.Send(objMsg);
                MessageBox.Show("mail send");
            
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

Answers (2)