0

Hi i'm new to asp.net & i'm developing an enquiry form for a website in asp.net 2003 which contains the foll fields:

Name:
Email id:
Message:
Submit

Submit is a button & on clicking it all the information entered in the above fields should be directed to the company email id. I've got a code from the net but it is not working. Pls Help me. Thanks

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by love_dude1984
0

try using following code,

add the namespaces,

using System.Web.Mail;
using System.Web.SessionState;
using System.ComponentModel;

modify the following code as per your convenience.

#region Code to send emails automatically
        //code for sending mail to Admin



        try
        {
            // Create a new blank MailMessage
            MailMessage email = new MailMessage();


            // Set the properties of the MailMessage to the
            // values on the form
            email.BodyFormat = MailFormat.Html;
            email.From = "email of the sender."
            email.To = "Email of the recipient"

            email.Subject = "Thank You";
            email.Body = "You can add as many lines as you want in body. just need to use following method.";
            email.Body += "add more lines like this";
            email.Body += " <br>Test line 1";
            email.Body += "Test Line 2";
            email.Body += "Thank You <br><br>";
            email.Body += "Regards,<br>";

            // Set the SMTP server and send the email
            SmtpMail.SmtpServer = "your smtp server's name";
            SmtpMail.Send(email);


            
        }
        catch (Exception ex)
        {
            // Print a much less friendly message informing the 
            // user about the exception that was risen

        }

hope this helps.

Thanks,

Edited by love_dude1984: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.