I need help with styling particular text sections in Gmail messages that I’m generating through Google Apps Script. I want to build an automated email system where only certain parts of the message content get special formatting.
My goal is to create a main heading that’s bold, underlined, and 13.5pt in size. I also need a secondary heading that’s bold, 10pt, with #990000 color. Plus I want to include bullet points in the message.
Is it possible to achieve this using HTML markup, or should I format the content in a Google Doc first and then transfer it to an email using Apps Script?
I have experience with Apps Script but I’m new to the Gmail API methods and HTML formatting. Most examples I found online show how to style the entire message body, but I can’t find guidance on styling just specific text portions.
You’re absolutely on the right track thinking about HTML markup. I’ve been automating Gmail through Apps Script for several years and can confirm that inline CSS within HTML tags is your best bet for granular text formatting. One thing that caught me off guard initially was email client compatibility - some clients strip out certain CSS properties, so stick to basic inline styles. For your main heading, something like <span style="font-weight: bold; text-decoration: underline; font-size: 13.5pt;">Your Heading</span>
works reliably. The Google Doc approach sounds tempting but it’s unnecessarily complicated and you lose precise control over the formatting. When you use GmailApp.sendEmail()
with the htmlBody
parameter, you can mix plain text with your styled HTML segments seamlessly. Just remember to test your emails across different clients because what looks perfect in Gmail might render differently in Outlook or mobile apps.
HTML markup is definitely the way to go for this. I’ve been working with Apps Script for email automation for about two years now and found that using HTML strings gives you much more control than the Google Doc approach. For your specific requirements, you can build your HTML content like this: use <h1 style="font-weight: bold; text-decoration: underline; font-size: 13.5pt;">
for your main heading, and <h2 style="font-weight: bold; font-size: 10pt; color: #990000;">
for the secondary heading. For bullet points, standard <ul>
and <li>
tags work perfectly. The key is using the htmlBody
parameter in your GmailApp.sendEmail()
method instead of just the body parameter. I learned this the hard way after spending hours wondering why my styling wasn’t showing up. Also make sure to wrap your entire content in basic HTML structure with proper opening and closing tags to ensure consistent rendering across different email clients.
just concatenate your html strings and use sendEmail with htmlBody option. ive done this tons of times and it works great. skip the google doc route - way too complicated for what your trying to do. inline css is your friend here.