SendMail – Sending Email in Peoplecode

---SendMail – Sending Email through peoplecode send mail function


Local string &NL = "<br>"; /* The new line character in html */
 
/* Setting the parameters for sendmail */
&MAIL_FLAGS = 0;
&MAIL_TO = "bharat@search.com";
/* &MAIL_CC = "email2@psoftsearch.com";
&MAIL_BCC = "email3@psoftsearch.com"; */
&MAIL_SUBJECT = "Test Email";
&MAIL_FILES = "";
&MAIL_TITLES = "";
 
/* Getting page field values */
&f_name = R9_EMP_NAME.FNAME.Value;
&l_name = R9_EMP_NAME.LNAME.Value;
 
/* Making the email body */
&MAIL_GREET = "<font face ='Arial'>Dear " | &f_name | " " | &l_name | "," | &NL | &NL;
&MAIL_TEXT1 = "This is a test email that contains an HTML table." | &NL |  &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;