Hello All,
I have one query.
I have a webform with some fields and a command button say sendmail.What i want to do is that whenever a user click on sendmail a mail should have to go to perticular emailid with all fields in the webform and in a tabular format.i.e. all the data in the mail must be display in the form of table.Please anybody send me the code its hurry for me.
My email ids are
Thanks & Regards
Prashant S. More

Nipun TomarRank #90 · 23K reputationPosted May 14, 2008, 9:30 PM EDT
mailmessage.IsBodyHtml = true; /// /// This method will send Email based on the parameters passed to it /// /// Name or IP address of the host used for SMTP transaction /// Recipients /// Sender /// Subject /// Body content of Email /// true if Email sent successfully else false public bool SendMail(string ServerName, string ToEmail, string FromEmail, string Subject, string Body) { bool success=false; MailMessage mailMessage = new MailMessage(); MailAddress fromAddress = new MailAddress(FromEmail); mailMessage.From = fromAddress; mailMessage.Body = Body; String[] stringTo = ToEmail.Split(';'); foreach (string s in stringTo) { if (s != "") mailMessage.To.Add(s); } mailMessage.Subject = Subject; SmtpClient smtpClient = new SmtpClient(); smtpClient.Host = ServerName; try { smtpClient.Send(mailMessage); success=true; } catch { success=false; } return success; }Prashant More87 reputationPosted May 19, 2008, 4:39 AM EDT
Hello Nipun,
Thanks for your reply.But my problem is not solved you send me the code for how to send mail and i need the code for how to send the textbx values of the form to the mail in the tabular form.Please send me that HTML code and how to attach it to aspx.cs file.
Thanks & Regards
Prashant S. More
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted May 19, 2008, 2:31 PM EDT
Page Having following field.
Name:TextBox(txtCName.Text)
Phone: TextBox(txtCphone.Text)
E-mail: TextBox(txtCmail.Text)
Comments:TextBox(txtCcomments.Text)
protected void btnSubmit_Click(object sender, EventArgs e)
{
//Mail to Company
string strHTML = null;
strHTML = "";
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + " Request for the Information: ";
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "
strHTML = strHTML + "";
strHTML = strHTML + "";
try
{
//sending mail to client
MailMessage mlMsgclient = new MailMessage(strFrom, txtCmail.Text);
mlMsgclient.Subject = "Request submission confirmation";
mlMsgclient.Body = strHTML;
mlMsgclient.IsBodyHtml = true;
SmtpClient emailtoClient = new SmtpClient();
emailtoClient.Send(mlMsgclient);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
}
}