Saturday, 14 December 2013

Failure Sending Mail

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      
        
        string to = "abcfrom@xyzfrom.in";
        string from = "abcto@xyzto.in";
        MailMessage message = new MailMessage(from, to);
        message.Subject = "Using the new SMTP client.";
        message.Body = @"Using this new feature, you can send an e-mail message from an application very easily.";
        SmtpClient client = new SmtpClient("smtp.server.com");
        client.EnableSsl = false;   
        client.UseDefaultCredentials = true;
 
        try
        {
            client.Send(message);
        }
        catch (Exception ex)
        {
            Response.Write("Exception caught in CreateTestMessage2():" + ex.ToString());
        }
 
    }
}

No comments: