I've just had a go at this, and here's a more flexible function. The previous example couldn't properly handle ranges of selected cells, this one can (but you could also add some better error checking for empty ranges!) Could easily be customized to have other ranges of brightness, hues, auto-calculation of max value, etc.:
/**
* Adds a custom menu to the active spreadsheet, containing a single menu item
* for invoking the readRows() function specified above.
* The onOpen() function, when defined, is automatically invoked whenever the
* spreadsheet is opened.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function onOpen() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var menu = [({name: "colorize", functionName: "colorize"})];
spreadsheet.addMenu("HSV Colors", menu);
}
/*
* Change saturation of cell background colors based on their values
*/
function colorize() {
// Prompt the user for a max value number.
var numberRange = Browser.inputBox('Colorize Range',
'Please enter the maximum number of your range' +
' (for example, "2"):',
Browser.Buttons.OK_CANCEL);
if (numberRange == 'cancel') {
return;
}
// Prompt the user for a hue number.
var hue = Browser.inputBox('Colorize Range',
'Please enter the hue (0-359)' +
' (for example, "128"):',
Browser.Buttons.OK_CANCEL);
if (hue == 'cancel') {
return;
}
var range = SpreadsheetApp.getActiveRange();
Logger.log('range:' + range);
var values = range.getValues(); // [][]
Logger.log('values:' + values);
var backgrounds = [];
for (var row = 0; row < range.getNumRows(); row++)
{
var rowBackgrounds = [];
for (var column = 0; column < range.getNumColumns(); column++)
{
var val = Number(values[row][column]);
if (isNaN(val))
{
val = 0;
}
var newColor = HSVtoHEX(hue,255*val/numberRange,200);
rowBackgrounds.push(newColor);
}
backgrounds.push(rowBackgrounds);
}
range.setBackgrounds(backgrounds);
}
// http://stackoverflow.com/a/17243070/1536038
function HSVtoHEX(h, s, v) {
Logger.log('h:'+h+' s:'+s + ' v:' + v);
var r, g, b, i, f, p, q, t;
// turn variables into degrees and percentages
h=h/360, s=s/255, v=v/255;
if (h && s === undefined && v === undefined) {
s = h.s, v = h.v, h = h.h;
}
i = Math.floor(h * 6);
f = h * 6 - i;
p = v * (1 - s);
q = v * (1 - f * s);
t = v * (1 - (1 - f) * s);
switch (i % 6) {
case 0: r = v, g = t, b = p; break;
case 1: r = q, g = v, b = p; break;
case 2: r = p, g = v, b = t; break;
case 3: r = p, g = q, b = v; break;
case 4: r = t, g = p, b = v; break;
case 5: r = v, g = p, b = q; break;
}
//http://stackoverflow.com/a/5624139/1536038
var result = "#" + ((1 << 24) + (Math.floor(r * 255) << 16) +
(Math.floor(g * 255) << 8) + Math.floor(b * 255))
.toString(16).slice(1);
Logger.log(result);
return result;
}
You can use Yet Another Mail Merge to produce what appears to be line breaks by breaking up the message content into different columns.
Wherever you need to see a line break, insert a column with a Break #
header. The cells below the header in that column should be blank.
In Google Sheets for instance, your columns might end up looking like this:
Email Address
, P1
, Break 1
, P2
, Break 2
, P3
, Break 3
and P4
In Gmail, compose the draft message like this. Also, make sure the font size for the breaks is set to small.
![enter image description here](https://i.stack.imgur.com/tuWv3.png)
Send yourself a test to verify. Here's the result I got with this configuration.
![enter image description here](https://i.stack.imgur.com/LOJvE.png)
Best Answer
This will get you up and running, but you'll probably want to either reduce the loop time or insert a check for if/when the cell is changed to something other than "Red", otherwise it'll just keep blinking until the loop completes.
Edit
Make sure you consider heavily the oversimplified nature of this script, as noted by Ruben in the comments below. There's plenty of room for this to be fleshed out to handle edge cases.