Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
C#
protected void btn_submit_Click(object sender, EventArgs e)
{
	Response.Redirect("newAccount.aspx");
	Session["Cust_Name"] = txt_username.Text;
	 
	MailMessage mail = new MailMessage();
	//SmtpClient SmtpServer = new SmtpClient("smtp.outlook.com");
	//mail.From = (txt_email.Text);
	mail.To.Add("firstName.lastName@companyName.com");              
	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 = ("smtp.mail.companyName.com");

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

	client.Send(mail);
}



I am a newbie at c#.net 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 System.mail.net
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
Updated 23-Jan-13 8:31am
v4
Comments
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

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900