开发者

.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();
    }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜