hai there,

Im using ASP .NET c#...
I have created form to send to email.
Im using try catch...
it giving that message that the email sended successfully.
But it didnt appear in my mail account.

I dont know where is the problem in the coding.
Please check the coding below...
if is it got any coding problem please let me know.

// System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0
        // System.Net.Mail.SmtpClient is the alternate class for this in 2.0
        SmtpClient smtpClient = new SmtpClient();
        MailMessage message = new MailMessage();

        try
        {
            MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);

            // You can specify the host name or ipaddress of your server
            // Default in IIS will be localhost 
            smtpClient.Host = "localhost";

            //Default port will be 25
            smtpClient.Port = 25;

            //From address will be given as a MailAddress Object
            message.From = fromAddress;

            // To address collection of MailAddress
            message.To.Add("ssmeshack@gmail.com");
            message.Subject = ddSubject.Text;

            // CC and BCC optional
            // MailAddressCollection class is used to send the email to various users
            // You can specify Address as new MailAddress("admin1@yoursite.com")
            //message.CC.Add("admin1@yoursite.com");
            //message.CC.Add("admin2@yoursite.com");

            // You can specify Address directly as string
            //message.Bcc.Add(new MailAddress("admin3@yoursite.com"));
            //message.Bcc.Add(new MailAddress("admin4@yoursite.com"));

            //Body can be Html or text format
            //Specify true if it  is html message
            message.IsBodyHtml = false;

            // Message body content
            message.Body = "Name : " + txtName.Text +
            "<br /><br />Designation : " + txtDesignation.Text +
            "<br /><br />Organisation : " + txtOrganisation.Text +
            "<br /><br />Contact Number : " + txtDesignation.Text +
            "<br /><br />Facsimile: " + txtFax.Text +
            "<br /><br />Email : " + txtEmail.Text +
            "<br /><br />Subject : " + ddSubject.Text +
            "<br />Message : " + txtMsg.Text;

            // Send SMTP mail
            smtpClient.Send(message);

            lblConfirm.Text = "Email successfully sent.";
        }
        catch (Exception ex)
        {
            lblConfirm.Text = "Send Email Failed.<br>" + ex.Message;
        }

thanks,
Meshack

Please can anyone help me....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.