Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6957693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:02:26+00:00 2026-05-27T15:02:26+00:00

In the past I have used something like this to send form fields in

  • 0

In the past I have used something like this to send form fields in an E-mail form asp.net, I am trying to format more the html email but I dont know how to pass the textbox value into the message can someone help me?

//OLD WAY
message.Body += "<b>Preferred contact method: </b> " + drp_contact_method.SelectedValue + "<br/>";//


protected void btnAction_Click(object sender, EventArgs e)
    {
        if ((Page.IsValid))
        {
            if (dpAction.SelectedValue.ToString()=="Submit" )
            {
            // define SMTP client

            SmtpClient smtp = new SmtpClient("IP HERE");
            //smtp.EnableSsl = true; 
            // smtp.UseDefaultCredentials = true;
            //create the mail message
            MailMessage message = new MailMessage();

            //From address will be given as a MailAddress Object
            message.From = new MailAddress("myemail@domain.com");


            //To address collection of MailAddress
            message.To.Add("ric.gutierrez@domain.com");
            message.Subject = "Pre-Registration Form";


            // Change to false to not include HTML 

            string bodyHTML = string.Empty;
            string bodyPlain = string.Empty;
            message.IsBodyHtml = true;

            bodyHTML = @"<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'
'http://www.w3.org/TR/html4/loose.dtd'>
<html lang='en'>
<head>
</head>
<body>
<table style='width:800px; border:1px solid #000;' cellpadding='10' cellspacing='0' align='center'>
<tr>
<td colspan='2' style='background-color:#009797; border-bottom:1px solid #000;'>
<h1 style='text-align:center; color:#FFF;'>Pre-Registration Information</h1></td>
</tr>
  <td style='width:600px; vertical-align:top;'>
<h4 style='font-family:Arial, Helvetica, sans-serif; color:#000;'><u>PATIENT INFORMATION</u></h4>
<p style='font-family:Arial, Helvetica, sans-serif; font-size:.8em; color:#000; line-height:1.5em;'>Last Name:</p>
+ txtLastName.Text + 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:02:27+00:00Added an answer on May 27, 2026 at 3:02 pm

    I think the cleanest way to do this is to use string.Format. First define your HTML as you currently have in bodyHTML, but put placeholders like {0} and {1} in the string. Then, plug in your form variables like this:

    var body = string.Format(
        bodyHTML, 
        HttpUtility.HtmlEncode(yourTextBox.Text), 
        HttpUtility.HtmlEncode(yourOtherTextBox.Text));
    

    That will substitute {0} with yourTextBox.Text and {1} with yourOtherTextBox.Text, with both values encoded properly for the HTML.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used FindControl in the past, prior to .NET 2.0/3.0. It seems like
In the past I have used Managed Direct X and DirectShow.Net to play a
In the past, I have not really used namespaces, but in this project I
So, I'm trying to consume a webservice using something like this: $client = new
Several of my ajax applications in the past have used GET request but now
In the past I have used MAPISendMail to launch Outlook (or whatever the desired
Excuse my limited knoweldge here. In the past I have used Steve Sanderson's method
I have used JMS in the past to build application and it works great.
I have used traditional version control systems to maintain source code repositories on past
I have used valgrinds massif tool to monitor memory usage in the past. Does

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.