Hi Paul,
You are welcome, I am glad my sample it giving you some ideas, if you need more info, please let me know.
Originally posted by paulyp
View Post
Alpha Software Mobile Development Tools: Alpha Anywhere | Alpha TransForm |
{ConditionStart:other_filename_other_1:{cont_doc_type_a5instance1}="Other"}
'-- Send notifications email back and fort Providers and BCI from a single button. ' We have 4 conditions that may affect where email will be sent and which message ' body to use from the a5Repository table using a5w_GetFromWebAppRepository() ' I start testing from the last condition ' arSigned and work my way back to the first in the nested if...end if below. function xbSendEmail as c (e as p) dim fromAddress as c = e._currentRowDataNew.AnnualReportfromReplyToEmail dim fromAlias as c = e._currentRowDataNew.CompanyName dim sendToAddress as c = e._currentRowDataNew.email dim bccAddress as c = e._currentRowDataNew.AnnualReportfromReplyToEmail dim ReportIsDueNow as L = convert_type(e._currentRowDataNew.ReportIsDueNow, "L") dim arReadyForReview as L = convert_type(e._currentRowDataNew.arReadyForReview, "L") dim arReviewCompleted as L = convert_type(e._currentRowDataNew.arReviewCompleted, "L") dim arSigned as L = convert_type(e._currentRowDataNew.arSigned, "L") dim arSignatureDate as d = convert_type(e._currentRowDataNew.arSignatureDate, "d") dim cfpStudentName as c = e._currentRowDataNew.cfpStudentName dim Provider1FullName as c = e._currentRowDataNew.Provider1FullName dim cfpProviderDueDate as d = convert_type(e._currentRowDataNew.cfpProviderDueDate, "d") dim CompanyName as c = e._currentRowDataNew.CompanyName dim emailBodyTemplate as c = "" dim ms as p ms.send_to = sendToAddress ms.send_to_cc = "" ms.send_to_bcc = bccAddress ms.from_email = fromAddress '-- Test record flags to build the message parameters from last flag to the first. if arSigned = .T. then '-- eMail sent from Provider ms.subject = "IEP Annual Report for " + cfpStudentName + " - Signed" emailBodyTemplate = a5w_GetFromWebAppRepository("IEP Annual Report - Signed") fromAddress = e._currentRowDataNew.email bccAddress = e._currentRowDataNew.email fromAlias = Provider1FullName sendToAddress = e._currentRowDataNew.AnnualReportfromReplyToEmail else if arReviewCompleted = .T. then '-- eMail sent from Company ms.subject = "IEP Annual Report for " + cfpStudentName + " - Review Completed" emailBodyTemplate = a5w_GetFromWebAppRepository("IEP Annual Report - Review Completed") else if arReadyForReview = .T. then '-- eMail sent from Provider ms.subject = "IEP Annual Report for " + cfpStudentName + " - Ready for Review" emailBodyTemplate = a5w_GetFromWebAppRepository("IEP Annual Report - Ready for Review") fromAddress = e._currentRowDataNew.email bccAddress = e._currentRowDataNew.email fromAlias = Provider1FullName sendToAddress = e._currentRowDataNew.AnnualReportfromReplyToEmail else if ReportIsDueNow = .T. then '-- eMail sent from Company ms.subject = "IEP Annual Report for " + cfpStudentName + " - Due Now" emailBodyTemplate = a5w_GetFromWebAppRepository("IEP Annual Report - Due Now") end if '-- ReportIsDueNow = .T. end if '-- arReadyForReview = .T. end if '-- arReviewCompleted = .T. end if '-- arSigned = .T. '-- Make sure the email body template is evaluated to get the field values ' stored in the template from {} variables. ms.message_html = evaluate_string(emailBodyTemplate) ms.message_text = "Plain text version of the message" '-- No attachements needed by this process. 'ms.attachments = "c:\files\mychart1.pdf,c:\files\mytext1.txt" '-- If for any reason the a5Repository record does not have a message body template, then ' exit this function. if alltrim(emailBodyTemplate) = "" then 'Return a Javascript command xbSendEmail = "alert('The email body is empty. Email was not sent.');" return end if '-- Send email here using Mandrill service. dim pResult as p dim mandrillKey as c = "" pResult = email_send_mandrill(mandrillKey,ms) if pResult.error then xbSendEmail = "alert('There was an error sending your email " + js_escape(pResult.result[1].status) + "');" else xbSendEmail = "alert('Your email was sent successfully to " + js_escape(sendToAddress) + "');" end if end function
Leave a comment: