Monday, 22 September 2014

Send Emails from Peoplecode

import PT_MCF_MAIL:*;
import PT_MCF_MAIL:MCFOutboundEmail;
import PT_MCF_MAIL:MCFEmail;

Local PT_MCF_MAIL:MCFOutboundEmail &email = create PT_MCF_MAIL:MCFOutboundEmail();
Local PT_MCF_MAIL:MCFBodyPart &html = create PT_MCF_MAIL:MCFBodyPart();
Local PT_MCF_MAIL:MCFBodyPart &attachment_Letter = create PT_MCF_MAIL:MCFBodyPart();
Local PT_MCF_MAIL:MCFMultipart &mp = create PT_MCF_MAIL:MCFMultipart();
Local string &NL = "<br>";
&go = True;

&email.Recipients = " munib776@yahoo.com";
&email.Subject = "Application Submission Confirmation - Test Email ";

/* Email Body */


&MAIL_GREET = "<font face ='sans-serif'>";
&MAIL_FOOTER = "</font>";


&smstxtL4 = "Copies of following Documents are required: " | &NL;

&smstxtL5 = "1.        Certificate & Mark sheet of SSC, O-Level Certificate or any other ." | &NL;
&smstxtL6 = "2.      Certificate & Mark Sheet of HSC, A-Level Certificate, High School Diploma,or any other (Equivalency from IBCC required)." | &NL;
&smstxtL7 = "3.        Bachelor's Degree and Mark sheet/ Transcript." | &NL;
&smstxtL8 = "4.        Master's Degree and Mark sheet/ Transcript." | &NL;
&smstxtL9 = "5.      National Identity Card or Form B." | &NL;
&smstxtL10 = "6.    Copy of Employment Certificate(s) for MBA (Weekend) candidates only. " | &NL;
&smstxtL11 = "7.    NTS GAT/Subject result for PhD Candidates." | &NL;
&smstxtL12 = "8.    Those  have A-Level or other International qualification must submit equivalency certificate issued by the IBCC. " | &NL;
&smstxtL13 = "9.    Two recent passport size photographs. " | &NL;
&smstxtL14 = "10.    Copies of documents must be attached starting with the last qualification." | &NL | &NL;
&smstxtL15 = "Note: Result awaiting candidates must submit Admit Card/ Statement of Entry." | &NL;









&smstxt = &MAIL_GREET | &smstxtL4 | &smstxtL5 | &smstxtL6 | &smstxtL7 | &smstxtL8 | &smstxtL9 | &smstxtL10 | &smstxtL11 | &smstxtL12 | &smstxtL13 | &smstxtL14 | &smstxtL15 | &MAIL_FOOTER;
&smstxt = Substitute(Substitute(Substitute(&smstxt, Char(13), " "), Char(10), " "), ",", " ");
&html.Text = &smstxt;









&html.ContentType = "text/html";
&html.Charset = "utf-8";


&mp.AddBodyPart(&html);
&email.MultiPart = &mp;

/* begin - uncomment for DEV only */
rem &email.SMTPServer = "10.71.32.74"; /* CSDVL SMTPServer */
rem &email.SMTPPort = 25; /*-- Usually this is 25 by default */
/* end - uncomment for DEV only */

Local integer &res = &email.Send();

Evaluate &res
When %ObEmail_Delivered
   /* every thing ok */
 
   &done = True;
   Break;
 
When %ObEmail_NotDelivered
   /*-- Check &email.InvalidAddresses, &email.ValidSentAddresses
and &email.ValidUnsentAddresses */
   &Err_Msg = &email.InvalidAddresses | "," | &email.ValidSentAddresses | "," | &email.ValidUnsentAddresses;
 
   &done = False;
   Break;
 
When %ObEmail_PartiallyDelivered
   /* Check &email.InvalidAddresses, &email.ValidSentAddresses
and &email.ValidUnsentAddresses; */
 
   &Err_Msg = &email.InvalidAddresses | "," | &email.ValidSentAddresses | "," | &email.ValidUnsentAddresses;
 
   &done = True;
   Break;
 
When %ObEmail_FailedBeforeSending
   /* Get the Message Set Number, message number;
Or just get the formatted messages from &email.ErrorDescription,
&email.ErrorDetails;*/
 
   &Err_Msg = &email.ErrorDescription | "," | &email.ErrorDetails;
 
   &done = False;
   Break;
End-Evaluate;

No comments:

Post a Comment