send emails with colours, tables and graphics, you have come to the right place. This post explains how to send html emails from peoplecode using the html option in sendmail. This can generate really good looking emails that stand out from the usual text only emails used for notifications. So here’s how we do it.
Local string &NL = "<br>"; /* The new line character in html */
/* Setting the parameters for sendmail */
&MAIL_FLAGS = 0;
&MAIL_TO = "email1@psoftsearch.com";
&MAIL_CC = "email2@psoftsearch.com";
&MAIL_BCC = "email3@psoftsearch.com";
&MAIL_SUBJECT = "Test Email";
&MAIL_FILES = "";
&MAIL_TITLES = "";
/* Making the email body */
&GREET = "<font face ="Arial">Dear " | &f_name | " " | &l_name | "," | &NL;
&MAIL_TEXT1 = "This is a test email that contains an HTML table." | &NL;
&MAIL_TEXT2 = "<table border='1'><tr bgcolor = '#AAAAAA' ><th>Name</th><th>State</th><th>Country</th></tr><tr><td>Rojer Alex</td><td>VA</td><td>USA</td></tr></table>" | &NL;
&TEXT1 = "Your footer line(s) goes here." | &NL | &NL;
&TEXT2 = "Regards," | &NL | "The PSoftSearch team";
&MAIL_FOOTER = &TEXT1 | &TEXT2 | "</font>";
&MAIL_TEXT_BODY = &MAIL_GREET | &MAIL_TEXT1 | &MAIL_TEXT2 | &MAIL_FOOTER;
/* Sending the email */
&RET_CODE = SendMail(&MAIL_FLAGS, &MAIL_TO, &MAIL_CC, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TEXT_BODY, &MAIL_FILES, &MAIL_TITLES, "", ";", "Content-type: text/html; charset=utf8");
/* Evaluating the return value of sendmail and showing the appropriate message */
If (&RET_CODE = 0) Then
MessageBox(0, "Alert", 0, 0, "Email has been sent.");
Else
MessageBox(0, "Alert", 0, 0, "Unable to send email.");
End-If;