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
{}