I am attempting to deliver a email message when i run my webform page to my personal email server address at Yahoo named [email protected] using my visual studio developer connected to internet. I am unable to succesfully send a message?
protected void btnSendEmail_Click(object sender, EventArgs e)
{
try
{
MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient();
message.From = new MailAddress("[email protected]");
message.To.Add(new MailAddress("[email protected]"));
message.Subject = "Test";
message.IsBodyHtml = true; //to make message body as html
message.Body = "";
smtp.Port = 587;
smtp.Host = "smtp.mail.yahoo.com"; //for gmail host
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("[email protected]", "testbedemail");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(message);
}
catch (Exception) { }
}