I have been trying to send mail through my c# website, but kinda stuck up somewhere and not able to figure out the problem. :-/
M getting SmtpException saying "Failure sending mail". Please help.:icon_confused:
MailAddress fromAddress = new MailAddress("abc@gmail.com", "n1");
MailAddress toAddress = new MailAddress("xyz@yahoo.co.in", "n2");
const string fromPassword = "pwd";
const string subject = "Subject";
const string body = "Body";
// SMTP Configuration
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential(fromAddress.Address, fromPassword);
// MAIL MESSAGE CONFIGURATION
MailMessage message = new MailMessage(fromAddress, toAddress);
message.Subject = subject;
message.Body = body;
// SEND EMAIL
smtp.Send(message);