2013-09-03

PeopleSoft - send attachment by email



When developing BI Publisher report, I usually use the script below to send the generated XML to my email address - which is much easier to exam the generated XML file.
-------------------------------------------------------------------------------------------------------

import PT_MCF_MAIL:MCFOutboundEmail;

Local string &str_FilePath, &str_FileName;
Local boolean &bSuccess;

/* Email the output */
Local PT_MCF_MAIL:MCFOutboundEmail &email = create PT_MCF_MAIL:MCFOutboundEmail();
&email.Recipients = "recipient1@zzzzzzz.yyy.xx;recipient2@xxxx.zzz.yy";
&email.Subject = "Subject Text";

&email.Text = "Email Body Text";
&email.AddAttachment(&str_FilePath | &str_FileName, %FilePath_Absolute, &str_FileName, "Invoice", "", "");

/* temp mail overrides */
rem &email.SMTPServer = "mail.company.com";
rem  &email.SMTPPort = 25;

Local number &rcEmail = &email.Send();
If &rcEmail = 1 Then
 /* email was successful */
 &bSuccess = True;
Else
 /* email failed */
 If &email <> Null Then
&MESSAGE_SET_NBR = &email.MessageSetNumber;
&MESSAGE_NBR = &email.MessageNumber;
&INVALID_EMAILID = &email.InvalidAddresses;
 End-If;
End-If;