hi, Tayyab nice to view ur little introduction through peoples. i am a beginner programmer of same technology. I have a problem . I want to send email through C# code but i am getting error. On send button click I have simply writtten the code:
private void btnSend_Click(object sender, System.EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = txtTo.Text;
mail.From = txtFrom.Text;
mail.Subject = txtSubject.Text;
mail.Body = txtBody.Text;
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(mail);
}
but I am getting following Error:
System.Runtime.InteropServices.COMException: The transport failed to connect to the server.
How to fix this error? Waiting for your reply
Tags: 1.1, asp.net, email, Sending