smtp exception "failure sending mail" in C#.net

Posted by Ajay_Kumar on Stack Overflow See other posts from Stack Overflow or by Ajay_Kumar
Published on 2010-12-23T08:39:06Z Indexed on 2010/12/23 8:54 UTC
Read the original article Hit count: 230

Filed under:
|
|

Hello, I am making smtp mail application c#.net.This is working ok for Gmail setting but i have to work it for VSNL connection.I am getting an error exception "Failure sending mail" my setting seems looks perfect.What is the exact problem ? why this exception coming ? Thanks

       MailMessage mailMsg = new MailMessage();

            MailAddress mailAddress = new MailAddress("[email protected]");

            mailMsg.To.Add(textboxsecondry.Text);

            mailMsg.From = mailAddress;


            // Subject and Body

            mailMsg.Subject = "Testing mail..";

            mailMsg.Body = "connection testing..";



            SmtpClient smtpClient = new SmtpClient("smtp.vsnl.net", 25);


            System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("[email protected]", "password");

            smtpClient.EnableSsl = true;

            smtpClient.UseDefaultCredentials = false;


            smtpClient.Credentials = credentials;

            smtpClient.Send(mailMsg);

© Stack Overflow or respective owner

Related posts about c#

Related posts about email