How to bold specific text using Google Apps Script?

前端 未结 3 1074
小蘑菇
小蘑菇 2020-12-16 07:17

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

Now, consider this code:

function sendFormByEmail(e)
{
         


        
3条回答
  •  臣服心动
    2020-12-16 07:50

    The answer that Abe.S provided is simpler. I combined it with part of arunes' edited answer. It's now written in the way its_me requested in their comment to arunes:

    function inlineImage() { 
       MailApp.sendEmail({
         to: "team@example.com",
         subject: e.namedValues["Subject"].toString(),
         htmlBody: "Time: " + e.namedValues["Timestamp"].toString() + "
    " + "Name: " + e.namedValues["Name"].toString() + "
    " + "Email: " + e.namedValues["Email Address"].toString() + "
    " + "Website: " + e.namedValues["Website"].toString() + "
    " + "Reason For Contacting?: " + e.namedValues["Reason For Contacting?"].toString() + "
    " + "Message: " + e.namedValues["Message"].toString() + "
    ", }); }

    I tested it with my own variables in place of all the "e.namedValues[..." for my application and it worked. I'm still a novice, so I'm not sure why doing the "msgPlain" to "msgHtml" replacement step would be better.

    By the way, I tried to write this as a comment, but I don't have enough points. Though I guess what I wrote is technically the answer that its_me was looking for originally. Many thanks to both Abe.S and arunes for teaching me about both scripts.

提交回复
热议问题