I am getting an Exception in Email program of asp.net.?

sandy48dh

New member
I am getting an Exception in Email program of asp.net , actually i am getting an error while submitting ( send method) , please guide me that how can i alter my program so that it could be mailed.......

SmtpClient serverobj = new SmtpClient();
// serverobj.UseDefaultCredentials = true;
serverobj.Credentials = new NetworkCredential(TextBox1.Text, TextBox5.Text);

serverobj.Host = "plus.smtp.mail.yahoo.com";
serverobj.Port = 465;
serverobj.EnableSsl = true;

msgobj = new MailMessage();
msgobj.From = new MailAddress(TextBox1.Text, "mail me info", System.Text.Encoding.UTF8);
msgobj.To.Add(TextBox2.Text);
msgobj.Priority = MailPriority.High;
msgobj.Subject = TextBox3.Text;
msgobj.Body = TextBox6.Text;
msgobj.Attachments.Add(new Attachment(MapPath("~/sandy1/" + TextBox4.Text)));
msgobj.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;


serverobj.Send(msgobj);
//The SMTP server requires a secure connection or the client was not authenticated
Label1.Text = "mail sent successfully";




please send me more correct code and gimme more information abt smtpserver
 
Back
Top