srinath

srinath

  • NA
  • 144
  • 0

e-mail sending

May 24 2010 2:00 AM

hi,

I am trying to code for sending an e-mail in asp.net 3.5 .
here I am getting an runtime exception. I tried below given code in the button click event for sending the e-mail.

protected void Button2_Click(object sender, EventArgs e)
    {
        MailMessage msg = new MailMessage();
        msg.To.Add("[email protected]");
        msg.From = new MailAddress("[email protected]");
        msg.Subject = txtsubject.Text;
        msg.Body = bodytxt.Text;
     //   msg.Attachments.Add(new Attachment(Server.MapPath("info.txt")));
        msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
        SmtpClient obj = new SmtpClient();
        obj.Host = "smtp.gmail.com";
        obj.Port = 587;
        obj.UseDefaultCredentials = false;
        obj.Credentials = new System.Net.NetworkCredential("[email protected]","94757");
        obj.EnableSsl = true;
      
        obj.Send(msg);
     //   Response.Write("Message Send");
    }


I am getting the exception as

      "check the response property of the exception to determine why request failed"
      "check the status property of the exception to determine why request failed".

please solve problem.

Thanks in advance.

Answers (2)