SendMail() vs MCFOutBoundEmail() Emailing Functions
1. Is the MCFOutBoundEmail() function
better than SendMail() function?
As of PT 8.49.13, PeopleSoft began using javamail via MultiChannel Framework (MCF) to send emails, as javamail is fully SMTP Protocol compliant to RFC 821/822. The MCFOutBoundEmail() function is fully compliant, whereas SendMail() function uses PeopleSoft's basesmtp.cpp, and has been found to not be fully compliant with SMTP Protocol RFC 821/822. Therefore, the recommendation is to replace use of SendMail, with MCFOutBoundEmail function.
As of PT 8.49.13, PeopleSoft began using javamail via MultiChannel Framework (MCF) to send emails, as javamail is fully SMTP Protocol compliant to RFC 821/822. The MCFOutBoundEmail() function is fully compliant, whereas SendMail() function uses PeopleSoft's basesmtp.cpp, and has been found to not be fully compliant with SMTP Protocol RFC 821/822. Therefore, the recommendation is to replace use of SendMail, with MCFOutBoundEmail function.
2. How does this function send email? is
it SMTP?
Yes, MCFOutBoundEmail sends email fully compliant to Simple
Mail Transfer Protocol (SMTP)
3. Where is SMTP Server & Port
configured?
MCFOutBoundEmail() function uses the SMTP section of the
Application Server's psappsrv.cfg file, and Process Scheduler's SMTP section of
the psprcs.cfg file, just as the SendMail() function does. No special
configuration is required for the MCFOutboundEmail() function to work.
Sample code using
MCFOutBoundEmail:
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();
&email.Recipients = "FINQAGenUser10@ap6023fems.us.oracle.com";
&email.From = "";
&email.BCC = "";
&email.Subject = "MCF Outbound Email test";
&email.ReplyTo = "";
&email.Text = "Email Body - This is a Test of the MCF Outbound Email";
&res = &email.Send();
import PT_MCF_MAIL:MCFOutboundEmail;
import PT_MCF_MAIL:MCFEmail;
Local PT_MCF_MAIL:MCFOutboundEmail &email = create PT_MCF_MAIL:MCFOutboundEmail();
&email.Recipients = "FINQAGenUser10@ap6023fems.us.oracle.com";
&email.From = "";
&email.BCC = "";
&email.Subject = "MCF Outbound Email test";
&email.ReplyTo = "";
&email.Text = "Email Body - This is a Test of the MCF Outbound Email";
&res = &email.Send();
One more example that
will send Email out in Bulk. Using this example would definitely improve
the performance of sending bulk email since there are no separate connections
getting created for each emails. This saves time spent creating and
closing connections.
import
PT_MCF_MAIL:MCFOutboundEmail;
import PT_MCF_MAIL:MCFBodyPart;
import PT_MCF_MAIL:MCFMultipart;
import PT_MCF_MAIL:MCFMailUtil;
import PT_MCF_MAIL:SMTPSession;
Local integer &noOfMails = 20;
Local array of PT_MCF_MAIL:MCFOutboundEmail &mails;
Local PT_MCF_MAIL:MCFOutboundEmail &email;
Local integer &i;
Local PT_MCF_MAIL:SMTPSession &commonSession = create PT_MCF_MAIL:SMTPSession();
&commonSession.Server = "ap6023fems.us.oracle.com";
&commonSession.Port = 25;
&mails = CreateArray(&email);
For &i = 1 To &noOfMails
&email = &commonSession.CreateOutboundEmail();
&email.From = "sender@sender.com";
&email.Recipients = "receiver@receiver.com";
&email.BCC = "sender@sender.com";
&email.Subject = "Mail: " | NumberToString("2.0", &i) | " Hi there";
&email.Text = "<HTML><BODY>Mail No: " | NumberToString("2.0", &i) | "One of multiple mails from from java</BODY></HTML>";
&email.ContentType = "text/html";
&mails &i = &email;
End-For;
Local PT_MCF_MAIL:MCFMailUtil &util = create PT_MCF_MAIL:MCFMailUtil();
Local array of integer &allRes = &commonSession.SendAll(&mails);
import PT_MCF_MAIL:MCFBodyPart;
import PT_MCF_MAIL:MCFMultipart;
import PT_MCF_MAIL:MCFMailUtil;
import PT_MCF_MAIL:SMTPSession;
Local integer &noOfMails = 20;
Local array of PT_MCF_MAIL:MCFOutboundEmail &mails;
Local PT_MCF_MAIL:MCFOutboundEmail &email;
Local integer &i;
Local PT_MCF_MAIL:SMTPSession &commonSession = create PT_MCF_MAIL:SMTPSession();
&commonSession.Server = "ap6023fems.us.oracle.com";
&commonSession.Port = 25;
&mails = CreateArray(&email);
For &i = 1 To &noOfMails
&email = &commonSession.CreateOutboundEmail();
&email.From = "sender@sender.com";
&email.Recipients = "receiver@receiver.com";
&email.BCC = "sender@sender.com";
&email.Subject = "Mail: " | NumberToString("2.0", &i) | " Hi there";
&email.Text = "<HTML><BODY>Mail No: " | NumberToString("2.0", &i) | "One of multiple mails from from java</BODY></HTML>";
&email.ContentType = "text/html";
&mails &i = &email;
End-For;
Local PT_MCF_MAIL:MCFMailUtil &util = create PT_MCF_MAIL:MCFMailUtil();
Local array of integer &allRes = &commonSession.SendAll(&mails);
Important! The SendMail function has been deprecated. Use the MCFOutboundEmail class instead.
The SendMail function was formerly used to send an email message from a PeopleSoft application page.
This change appears in 8.52 and 8.53 hosted document update
Comments
Post a Comment