Click here to Skip to main content
12,752,876 members (38,339 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
How would I configure this to actually send the form contents to an Outlook address?

This is what I have and it does not work.
protected void btn_submit_Click(object sender, EventArgs e)
	Session["Cust_Name"] = txt_username.Text;
	MailMessage mail = new MailMessage();
	//SmtpClient SmtpServer = new SmtpClient("");
	//mail.From = (txt_email.Text);
	mail.Body = (txt_name.Text + txt_company.Text + txt_address.Text + txt_city.Text + ddl_state.Items + txt_zipcode + txt_phone.Text + txt_email.Text + txt_username.Text + txt_pass.Text);
	SmtpClient client = new SmtpClient();
	client.Host = ("");

	client.Port = 1024;
	client.EnableSsl = true;


I am a newbie at coding, what I have is a "registration form" that when you click the submit button the data from the form will be emailed to the "Administrator" who will manually add the information to a database.

I know there is a better way of doing this, but this is how they want it done, since the Administrators email is an outlook account I would have to email the form contents to that.

I didn't know that it had nothing to do with outlook, I understood that you set up the
and entered information for the SMTP client, Do you have a good link to a tutorial that will show me how to achieve this?
Posted 23-Jan-13 8:17am
Updated 23-Jan-13 9:31am
BC @ CV2.6K
BC @ CV 23-Jan-13 13:59pm
What is the error you are getting? You do know this code has nothing to do with Outlook, right?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

If I had to guess at your error, which I will have to since you didn't post it, I would say you are missing the SMTP server password. Read this. Hope it helps.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 23 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100