tags:

views:

87

answers:

2
try
{
  MailMessage m = new MailMessage("[email protected]", "[email protected]", "Situação", "Oi, tudo bem?");
  SmtpClient smtp = new SmtpClient("smtp.live.com", 587);
  smtp.Credentials = new NetworkCredential("[email protected]", "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

A: 
    try
    {
        MailMessage m = new MailMessage("[email protected]", "[email protected]", "Situação", "Oi, tudo bem?");
        SmtpClient smtp = new SmtpClient("smtp.live.com", 587);
    smtp.UseDefaultCredentials = false;
        smtp.EnableSsl = true;            
        smtp.Credentials = new NetworkCredential("[email protected]", "YourPassword", "");

        smtp.Send(m);
        Console.WriteLine("sucesso");
    }
    catch (SmtpException ex)
    {
        Console.WriteLine(ex.Message);
    }
    finally
    {
        Console.ReadKey();
    }
zadeveloper
A: 

Jeff Atwood discusses sending emails on his blog, you might find it useful in fixing your problem, and potentially others you unaware of.

http://www.codinghorror.com/blog/2010/04/so-youd-like-to-send-some-email-through-code.html

WanderingThoughts