Problem with smtp mailing system

Discussion in 'Email' started by jayee, Jun 25, 2010.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi guys,
    Forgive me for my ignorance. Please have a look at the code snippet and let me know where I am doing wrong?

    I hosted it on discountasp.net and I followed exactly what they advised.

    Every time i am getting exception.

    Thanks in advance





    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
    MailMessage mail = new MailMessage();


    mail.From = new MailAddress(TextBoxEmail.Text, TextBoxCompanyName.Text);
    mail.To.Add(new MailAddress("[email protected]"));
    //mail.To.Add(new MailAddress("[email protected]"));
    mail.Subject = TextBoxSubject.Text;
    mail.Body = TextBoxMessage.Text;

    SmtpClient client
    = new SmtpClient("smtp.achirconsultancy.com");
    client.Credentials = new System.Net.NetworkCredential("[email protected]", "xxxxxxx");
    try
    {

    client.Port = 25;
    client.Send(mail);
    }
    catch (Exception ex)
    {
    Labeltext.Text = " Error occured. Sorry for the inconvinence";
    return;
    /*Response.Write(" Unhandled expection occured please check the Email ID that you have entered");*/

    }

    Labeltext.Text = "Your message has been successfully sent. Thank you";

    }
     
  2. Bruce

    Bruce DiscountASP.NET Staff

  3. What exeption are you getting??
    Maybe you should try to use different code lines to specify mail.From, this is what you have:

    mail.From = new MailAddress(TextBoxEmail.Text, TextBoxCompanyName.Text);

    This is what I'll use:

    mail.From = new MailAddress(TextBoxEmail.Text);
    mail.From = new MailAddress(TextBoxCompanyName.Text);
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page