Tuesday, December 28, 2010

Email Using Application Package

The Application Package is easier to use, and in my opinion more reliable with HTML text than the function SendMail() which has been traditionally used.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: */
/* myname@mydomain.com – if multiple addresses then */
/* separate by commas */
/* &Email_Address_From takes standard email format: */
/* myname@mydomain.com */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* 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;

1 comment:

  1. The Star Grand at The Star Gold Coast | JTM Hub
    Guests can 강릉 출장마사지 enjoy an array 남원 출장마사지 of live 광명 출장샵 entertainment venues, including bars, restaurants, theatre and a theatre. 서울특별 출장안마 In 경산 출장샵 addition to Dec 16, 2021 · Uploaded by JTM

    ReplyDelete