2
Answers

How can i eliminate this error??

asif basha

asif basha

15y
2.4k
1
 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
Answers (2)