Sending email from Windows form application
Hi everyone,
I hv been using the code below to send emails with much success but now it doesn't work any more. Any help will be much appreciated.
Code
public void SendEmail()
{
try
{
SmtpClient clientSMTP = new SmtpClient("smtp.gmail.com", 587);
clientSMTP.EnableSsl = true;
clientSMTP.DeliveryMethod = SmtpDeliveryMethod.Network;
clientSMTP.UseDefaultCredentials = false;
clientSMTP.Credentials = new NetworkCredential("[email protected]", "password");
using(MailMessage message = new MailMessage())
{
message.From = new MailAddress("yourgmailid @gmail.com");
message.Subject = "Subject";
message.IsBodyHtml = true;
message.To.Add("[email protected]");
message.Body = "Hi " + "Suresh" + "!\n" + "Welcome to C# Corner!" + "Please click here to activate your account. \nThanks!";
clientSMTP.Send(message);
}
}
catch (Exception ex)
{}
finally
{}


Nitin SontakkeRank #264 · 9.6K reputationPosted Aug 2, 2016, 4:30 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Aug 2, 2016, 4:20 AM EDT
Marvin kakuruRank #3,979 · 374 reputationPosted Aug 2, 2016, 4:25 AM EDT
Marvin kakuruRank #3,979 · 374 reputationPosted Aug 2, 2016, 5:05 AM EDT
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Aug 2, 2016, 5:59 AM EDT
Tapan PatelRank #614 · 3.9K reputationPosted Aug 2, 2016, 6:01 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Aug 2, 2016, 7:08 AM EDT
Vinay SinghRank #604 · 4K reputationPosted Aug 2, 2016, 9:07 AM EDT
Jisny AvRank #4,868 · 321 reputationPosted Aug 10, 2016, 9:02 PM EDT
using System.Net;
try
{
MailMessage msg = new MailMessage(from, to));
msg.Subject = "mail subject";
msg.IsBodyHtml = true;
msg.Body = string.Format(mailbody);
SmtpClient mailclient = new SmtpClient("smtpout.asia.secureserver.net");
mailclient.UseDefaultCredentials = false;
mailclient.Credentials = new NetworkCredential(userid, pwd));
mailclient.DeliveryMethod = SmtpDeliveryMethod.Network;
mailclient.EnableSsl = false;
mailclient.Send(msg);
}
catch (Exception err)
{
}
}