Not Sending mail in Net 4 or Net 4.5

Discussion in 'ASP.NET / ASP.NET Core' started by Tiberiu, Aug 24, 2014.

  1. PLEASE HELP
    >
    > Website was working on the other host. The code is the same, but it does not work on DiscountASP.NET host
    >
    > Here is the code that I am using. Password is blocked wit xxx
    >
    > protected void btSend_Click(object sender, EventArgs e)
    > { StringBuilder sb=new StringBuilder();
    > sb.AppendLine("NoDemo ");
    > sb.AppendLine("--------------------- ");
    > sb.AppendLine("Salesman: "+tbYourName.Text.Trim());
    > sb.AppendLine("Customer: "+tbCustomer.Text.Trim());
    > sb.AppendLine("Time In House: "+ddHouseTime.Text.Trim());
    > sb.AppendLine("Reason No Demo: "+tbReason.Text.Trim());
    >
    > try
    > {
    > MailMessage mail = new MailMessage();
    > SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
    >
    > mail.From = new MailAddress("[email protected]");
    > mail.To.Add(jack.SendEmailsTo("NotDemo"));//this function bring an email address
    > mail.Subject = "No Demo for " + tbCustomer.Text.Trim() + " Salesman: " + tbYourName.Text.Trim();
    >
    > mail.Body =sb.ToString();
    >
    > SmtpServer.Port = 587;
    > SmtpServer.Credentials = new System.Net.NetworkCredential("[email protected]", "XXXXXXX");
    > SmtpServer.EnableSsl = true;
    >
    > SmtpServer.Send(mail);
    > lbMessage.Text = "Mail Send";
    > }
    > catch (Exception ex)
    > {
    > lbMessage.Text = "Mail NOT Send";
    > }
    > }
     
  2. FrankC

    FrankC DiscountASP.NET Staff

    what is the exception?
     

Share This Page