0% found this document useful (0 votes)
25 views

Email

This document contains code that defines a function to send an email. It instantiates an email object, sets properties like the from/to addresses, subject, and body, and calls a send method. Based on the result, it displays success or error messages, checking error properties for failed messages.

Uploaded by

Karmveer Soni
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Email

This document contains code that defines a function to send an email. It instantiates an email object, sets properties like the from/to addresses, subject, and body, and calls a send method. Based on the result, it displays success or error messages, checking error properties for failed messages.

Uploaded by

Karmveer Soni
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Import PT_MCF_MAIL:*;

Local PT_MCF_MAIL:MCFOutboundEmail &email;


Local boolean &done;
Local integer &res;
Function Email_Example(&Email_Address_To As string, &Email_Address_From As
string, &Subject As string,
&BodyText_or_HTML as string, &ContentType as string);
/*
/*
/*
/*
/*
/*
/*

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
&Email_Address_To takes standard email format:
[email protected] if multiple addresses then
separate by commas
&Email_Address_From takes standard email format:
[email protected]
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

*/
*/
*/
*/
*/
*/
*/

/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Instantiate the App Package Class
*/
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
&email = create PT_MCF_MAIL:MCFOutboundEmail();
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Set Email Object Properties
*/
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
&email.From = &Email_Address_From;
&email.Recipients = &Email_Address_To;
&email.Subject = &Subject;
&email.Text = &BodyText_or_HTML;
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/* Could be "text/plain", "text/html", or
/*
"multipart/alternative"
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
&email.ContentType = &ContentType;

*/
*/
*/
*/

/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Invoke the method to generate the email
*/
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
&res = &email.Send();
Evaluate &res
When %ObEmail_Delivered
/* every thing ok */
&done = True;
MessageBox(0, "", 0, 0, "Email Sent Successfully");
Break;
When %ObEmail_NotDelivered
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/* Check &email.InvalidAddresses, &email.ValidSentAddresses
/*
and &email.ValidUnsentAddresses
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
&done = False;

*/
*/
*/
*/

MessageBox(0, "", 0, 0, "Email Not delivered" |


&eMail.InvalidAddresses | &eMail.ValidSentAddresses |
&eMail.ValidUnsentAddresses);
Break;
When %ObEmail_PartiallyDelivered
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/* Check &email.InvalidAddresses, &email.ValidSentAddresses
/*
and &email.ValidUnsentAddresses
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

*/
*/
*/
*/

&done = True;
MessageBox(0, "", 0, 0, "Email Partially delivered" |
&eMail.InvalidAddresses | &eMail.ValidSentAddresses |
&eMail.ValidUnsentAddresses);
Break;
When %ObEmail_FailedBeforeSending
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/* Get the Message Set Number, message number;
/*
Or just get the formatted messages from
/*
&email.ErrorDescription, email.ErrorDetails;
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
&done = False;
MessageBox(0, "", 0, 0, "Email Failed Before Sending" |
&eMail.ErrorDescription | &eMail.ErrorDetails);
Break;
End-Evaluate;
End-Function;

*/
*/
*/
*/
*/

You might also like