Creating a Text Email

The following code example creates and sends a very simple email, then tests the results.

import PT_MCF_MAIL:*;

/*-- Create an outbound email object --*/
Local PT_MCF_MAIL:MCFOutboundEmail &eMail = 
create PT_MCF_MAIL:MCFOutboundEmail();
/*-- Initialize the usual fields of an email --*/
&eMail.From = &FromAddress;
&eMail.Recipients = &ToList;
&eMail.Subject = &Subject;
&eMail.Text = &MailBody;
/*-- The send method uses the default SMTP parameters as set in the app server⇒
 configuration file. 

This send method makes a connection to the SMTP server, sends the mail and then⇒
 disconnects.

The result are returned as a number corresponding to the possible values. 

The list of ValidSent, InvalidSent and Invalid addresses are returned in the email⇒
 object itself
----*/
Local integer &resp = &eMail.Send();
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;