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

  • Home
  • SEARCH
  • 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 7548311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:39:59+00:00 2026-05-30T09:39:59+00:00

I use Google Spreadsheets’ built-in form functionality to build contact forms on my website.

  • 0

I use Google Spreadsheets’ built-in form functionality to build contact forms on my website.

Now, consider this code:

function sendFormByEmail(e)
{

  var email = "team@example.com";

  subject = e.namedValues["Subject"].toString();

  message = "Time: " + e.namedValues["Timestamp"].toString() + "\n\n"
  + "Name: " + e.namedValues["Name"].toString() + "\n\n"
  + "Email: " + e.namedValues["Email Address"].toString() + "\n\n"
  + "Website: " + e.namedValues["Website"].toString() + "\n\n"
  + "Reason For Contacting?: " + e.namedValues["Reason For Contacting?"].toString() + "\n\n"
  + "Message: " + e.namedValues["Message"].toString() + "\n\n";

  MailApp.sendEmail(email, subject, message);

}

It makes sure that I receive an email as soon as someone submits the form, the email’s body has info. like this (example):

Time: 2012/02/25 11:53

Name: John Davis

Email: John@google.com

Website: http://google.com

Reason For Contacting?: Just wanted to chat with ya

Message: It’s been long. Catch me tonight.

So, now you should have a clear idea as to what the code does. The thing is, I want the output to look like this instead (i.e., bold some text):

Time: 2012/02/25 11:53

Name: John Davis

Email: John@google.com

Website: http://google.com

Reason For Contacting?: Just wanted to chat with ya

Message: It’s been long. Catch me tonight.

How do I modify the code to achieve this? Thanks.

  • 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-30T09:40:00+00:00Added an answer on May 30, 2026 at 9:40 am

    MailApp.sendEmail can take htmlBody as advancedArgs. Descripted in here http://code.google.com/googleapps/appsscript/class_mailapp.html

    You can send htmlBody like

    function sendFormByEmail(e) {
        var email = "team@example.com";
        var subject = e.namedValues["Subject"].toString();
        var msgHtml = "<b>Time</b>: " + e.namedValues["Timestamp"].toString() + "<br/>"
            + "<b>Name:</b> " + e.namedValues["Name"].toString() + "<br/>"
            + "<b>Email:</b> " + e.namedValues["Email Address"].toString() + "<br/>"
            + "<b>Website:</b> " + e.namedValues["Website"].toString() + "<br/>"
            + "<b>Reason For Contacting?:</b> " + e.namedValues["Reason For Contacting?"].toString() + "<br/>"
            + "<b>Message:</b> " + e.namedValues["Message"].toString() + "<br/>";
    
        var msgPlain = msgHtml.replace(/\<br\/\>/gi, '\n').replace(/(<([^>]+)>)/ig, ""); // clear html tags and convert br to new lines for plain mail
        MailApp.sendEmail(email, subject, msgPlain, { htmlBody: msgHtml });
    }
    

    The above one’s for linebreaks. Use this to separate them by paragraphs:

    function sendFormByEmail(e) {
        var email = "team@example.com";
        var subject = e.namedValues["Subject"].toString();
        var msgHtml = "<p>" + "<b>Time</b>: " + e.namedValues["Timestamp"].toString() + "</p>"
            + "<p>" + "<b>Name:</b> " + e.namedValues["Name"].toString() + "</p>"
            + "<p>" + "<b>Email:</b> " + e.namedValues["Email Address"].toString() + "</p>"
            + "<p>" + "<b>Website:</b> " + e.namedValues["Website"].toString() + "</p>"
            + "<p>" + "<b>Reason For Contacting?:</b> " + e.namedValues["Reason For Contacting?"].toString() + "</p>"
            + "<p>" + "<b>Message:</b> " + e.namedValues["Message"].toString() + "</p>";
    
        var msgPlain = msgHtml.replace(/(<([^>]+)>)/ig, ""); // clear html tags for plain mail
        MailApp.sendEmail(email, subject, msgPlain, { htmlBody: msgHtml });
    }
    

    I didnt try but it should work.

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

Sidebar

Related Questions

I want to use Google spreadsheets to store data online so multiple people can
I want to use google chrome as a control. I think Enso does this
In Google Docs Spreadsheets, one can use Range Names to put labels on ranges
I am trying to use Google Docs Form in a custom HTML page. So
I am trying to learn how to use the Google Spreadsheets API through the
I would normally use Google analytics because it is free and simple to implement
I'm wanting to use google maps and see a million ways to do it
I am willing to use Google Analytics to track stats about usage of my
I'm trying to use Google Guice with the @Inject and @Singleton properties as follows:
Anyone know how to use Google Analytics for a Drupal-powered company intranet site behind

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.