1

I upload it on server it is not working. The error is : Failure sending mail. please tell me where is the problem.

    string username = "abc@gmail.com";   
    string password = "abc";

    SmtpClient smtpclient = new SmtpClient("smtp.gmail.com");
    smtpclient.Port = 465;
    smtpclient.UseDefaultCredentials = false;
    smtpclient.Credentials = new System.Net.NetworkCredential(username, password);
    smtpclient.EnableSsl = true;
    smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network;
    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();  
    MailAddress fromaddress = new MailAddress(username);   

    mail.From = fromaddress; 
    mail.To.Add("xxxxx@gmail.com");
    mail.Subject = ("Test Subject");
    mail.IsBodyHtml = true; logic
    mail.Body = TextBox2.Text;

    try
    {

        smtpclient.Send(mail);
        Response.Write("<B>Email Has been sent successfully.</B>");
    }
    catch (Exception ex)
    {

        Response.Write(ex.Message);
aom Kta
  • 11
  • 2

0 Answers0