0

Is it possible to use css in the variable i use that keeps html data with google apps script in a spreadsheet? It seems to ignore the <style>..</style> section completely. Anyone else tried this? I'm trying to format the confirmation email to have some nice looks. Thanks!

4

2 回答 2

2

这与 Google Apps 脚本无关。

Gmail会在显示任何电子邮件<style>时去除标签。 您需要使用内联样式。

于 2013-05-27T14:09:54.187 回答
1

是的,您仍然可以执行内联样式并将脚本参数嵌入到:

    function sendMeMail() {
       ...
// form HTML
       var htmlBodyText = wrapHTML();
       ...
// send email

       MailApp.sendEmail(
           imail,
           subject,
           subject,
             { htmlBody: htmlBodyText,
               inlineImages: 
                   { Logo: myLogo

                   },
               noReply: true
             }
       );
    ...
    }

出于说明目的:您可以看到如何使用不同的 css 样式和颜色格式

    function wrapHTML() {

       //initialize static parameters
       var myNumbers = new staticNumbers();
       var myPatterns = new staticPatterns();
       var myStyles = new staticStyles();



      var htmlBodyText = '<img src="cid:myLogo" style="background-color:'+myStyles.colorSheetLogo+'">';

      htmlBodyText += '<hr style="height:2px;border-width:2;color:"f8cB9c";background-color:rgb(135,206,250)" /><br><br>';
      htmlBodyText += '<a href='+myPatterns.myUrl+' style="font-size:150%">Hello! </a>'+'<br><br>';

      htmlBodyText += '<table border="1 cellpadding="20"">';

      htmlBodyText += '<colgroup span="'+myNumbers.numberOfColumns+'" <col style="background-color:'+myStyles.colorBgTitleRow+'"> </colgroup>';

      return(htmlBodyText);


     }  
于 2013-08-30T18:20:35.137 回答