Creating Email and Overriding SMTP Settings
The following code example creates a text email and overrides the SMTP settings as found in the application server configuration file.
import PT_MCF_MAIL:*;
/*-- Create an email object by setting individual parameters ---*/
Local PT_MCF_MAIL:MCFOutboundEmail &eMail =
create PT_MCF_MAIL:MCFOutboundEmail();
&eMail.Recipients = &ToList; /* comma separated list of email addresses */
&eMail.CC = &CCList; /* comma separated list of email addresses */
&eMail.BCC = &BCCList; /* comma separated list of email addresses */
&eMail.From = &FromAddress; /* from email address */
&eMail.ReplyTo = &ReplyToAddress; /* in case the reply is to be sent to a⇒
different email address */
&eMail.Sender = &SenderAddress; /* If different from the "from" address */
&eMail.Subject = &Subject; /* email subject line */
&eMail.Text = &MailBody; /* email body text */
/*-- Override the default SMTP parameters specified in app server configuration⇒
file ----*/
&eMail.SMTPServer = "psp-smtpg-01";
&eMail.SMTPPort = 10266; /*-- Usually this is 25 by default */
Local integer &resp = &eMail.Send();
/* Now check the &resp for the result */
Local boolean &done;
Evaluate &resp
When %ObEmail_Delivered
/* every thing ok */
&done = True;
Break;
When %ObEmail_NotDelivered
&done = False;
MessageBox(0, "", &email.MessageSetNumber, &email.MessageNumber, "PeopleTools error not found", &email.GetErrorMsgParam(1), &email.GetErrorMsgParam(2));
Break;
When %ObEmail_PartiallyDelivered
&done = True;
Break;
When %ObEmail_FailedBeforeSending
&done = False;
MessageBox(0, "", &email.MessageSetNumber, &email.MessageNumber, "PeopleTools error not found", &email.GetErrorMsgParam(1), &email.GetErrorMsgParam(2));
Break;
End-Evaluate;