Click here to Skip to main content
15,906,624 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want a complete form that takes the customer contact number , address, type of customer, his interest in, and his query to be sent to an email id. how to send all this through asp.net(c#)and i want it to appear all this separately in mailbox? i have tried to send all this with message body but its not giving a good look. please help. the code is below
Posted
Updated 7-Jul-12 2:53am
v4
Comments
[no name] 7-Jul-12 7:29am    
"i have tried to send".. oh? And where is the code that demonstrates any kind of a problem?

"pls"... maybe you can translate this.
saadiqa 7-Jul-12 8:34am    
protected void Button1_Click(object sender, EventArgs e)
{
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();

try
{
MailAddress fromAddress = new MailAddress(TextBox2.Text, TextBox3.Text);

// You can specify the host name or ipaddress of your server
// Default in IIS will be localhost
smtpClient.Host = "smtp.gmail.com";
smtpClient.Credentials = new NetworkCredential(TextBox2.Text,TextBox7.Text);
smtpClient.EnableSsl = true;
//Default port will be 25
smtpClient.Port = 587;

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

// To address collection of MailAddress
message.To.Add("heenalucknow@gmail.com");
message.Subject = "inquery";


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

// Message body content

message.Body = "contact:" + TextBox4.Text + "\n\n\n" + "address : \n" + TextBox5.Text + "\n query: \n" + TextBox6.Text;
// Send SMTP mail
smtpClient.Send(message);

Label1.Text = "Email successfully sent.";
}
catch (Exception ex)
{
Label1.Text = "Send Email Failed." + ex.Message;
}
}
[no name] 7-Jul-12 9:43am    
"\n" is not a recognizable HTML tag. New line in HTML is "<br>"

Have you tried anything for sending email saadiqa?? you have to prepare a HTML table or have to send all the field in your email body text.Try something and if you got stuck anywhere then ask for a help. then all will welcome your query. Its not a good habbit to ask for a code or some thing..

Thanks
Ashish
 
Share this answer
 
Comments
saadiqa 7-Jul-12 5:16am    
i know !!!!!!!
AshishChaudha 7-Jul-12 6:41am    
Then, please show us the code what you have tried..help will be more effective..
Thanks
Good, go ahead and do it. Do tell us if you get stuck and have issue.

Try out, it's not that tough, you need:
1. To textbox
2. Subject textbox
3. Contact number textbox
4. Address textbox
5. Type of customer textbox
6. Customers interest in doprdown
7. His query textarea
8. send email button
Total 15 controls (+ 7 labels for caption is already added) on a form designed to look good.

Once you have it, put send email code in the send button. Have a defined/default 'from email address'. Done!

Try!
 
Share this answer
 
Comments
saadiqa 7-Jul-12 5:16am    
i have tried this, but everything is being sent in a single line in mailbox. i want to appear like first the topic then its textbox item ...
Sandeep Mewara 7-Jul-12 13:18pm    
Sharing your related code snippet of implementation would had helped!
Hi,
Have you solved your problem with the above solutions.if not use the below code

Use Smtp client to initiate the mail instance and message body in html.

Thanks
Buy Lace
 
Share this answer
 
Comments
Nagy Vilmos 7-Jul-12 15:16pm    
I for the spam link.
saadiqa 30-Sep-12 0:56am    
please explain your soln in detail.. thank u

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