开发者

.NET Error sending email

开发者 https://www.devze.com 2023-01-17 23:06 出处:网络
try { MailMessage m = new MailMessage(\"testesmtpmi@hotmail.com\", \"myEmail@gmail.com\", \"Situação\", \"Oi, tudo bem?\");
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();
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号