MailMessage mail = new MailMessage();
mail.To = "[email protected]";
mail.From = "[email protected]";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body.";
MailAttachment attachment = new MailAttachment(Server.MapPath("somemail1.txt")); //create the attachment
mail.Attachments.Add(attachment); //add the attachment
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send(mail);
While running this code Im gettin error saying:transport failed to connect to the server
Loading
Pedro BarbasPosted Aug 20, 2009, 5:35 AM
This is a network related error. Your application cannot connect to the mail server specified
dont forget to mark this as "Accepted Answer" if you liked it
Roei BarPosted Aug 20, 2009, 6:41 AM
the Exception is as said before me, that you are not permitted to connect to the Server, you can test this by trying to
Telnet
if you fail do the above if you succeed write it down and i will see if i can figure it out :-)