The following code works correctly. You just want to change the SMTP client settings. I have tried it. It is working rightly.
Using System.Net.Mail;
Using System.Net;
private void btnsend_Click(object sender, EventArgs e)
{
MailMessage mail;
SmtpClient Smtp;
Smtp = new SmtpClient("techfuelsmtp.com", 25);
Smtp.Credentials = new NetworkCredential("<email_id>", "abcd");
Mail = new MailMessage("<email_id>", "<email_id>", "fsddsf", " fsddsf ");
Smtp.Send(Mail);
Mail.Dispose();
}
You also need to change the setting in web.config file.
<system.net>
<mailSettings>
<smtp from="test@foo.com">
<network host="smtpserver1" port="25" userName="username" password="secret" defaultCredentials="true" />
</smtp>
</mailSettings>
</system.net>



Reply With Quote

Bookmarks