.NET Error sending email
try
{
MailMessage m = new MailMessage("testesmtpmi@hotmail.com", "myEmail@gmail.com", "Situação", "Oi, tudo bem?");
SmtpClient smtp = 开发者_开发技巧new SmtpClient("smtp.live.com", 587);
smtp.Credentials = new NetworkCredential("testesmtpmi@hotmail.com", "xxxx");
smtp.EnableSsl = true;
smtp.Send(m);
Console.WriteLine("sucesso");
}
catch (SmtpException ex)
{
Console.WriteLine(ex.Message);
}
finally
{
Console.ReadKey();
}
whats wrong in here please? its join in catch and say Failure sending email
try
{
MailMessage m = new MailMessage("WindowsLiveUserName@live.com", "myEmail@gmail.com", "Situação", "Oi, tudo bem?");
SmtpClient smtp = new SmtpClient("smtp.live.com", 587);
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential("WindowsLiveUserName@live.com", "YourPassword", "");
smtp.Send(m);
Console.WriteLine("sucesso");
}
catch (SmtpException ex)
{
Console.WriteLine(ex.Message);
}
finally
{
Console.ReadKey();
}
精彩评论