Postgre Query results as Email HTML table

Hello,

I'm trying to send email from Greenplum query results as HTML table with status Red/Green

Select Server, Last_Date from Table;

Results

Server, Last_Date
Prod, 2018-04-09

Final email Output in HTML format

Server   Status       LastDate
Prod    GREEN(BOX)  2018-04-09 (if the date is within 24 hours) - Green color status
UAT     RED (BOX)   2018-04-08 (if the date not within 24 hours) -- Red color Status

What have you tried?

You can get some ideas from this thread: