E9.05.607B/Progress
Has anyone ever had a problem with the Send Email routine? I am trying to do what should have been a very simple BPM to generate an email alert on the POApvMsg.Update() bo.
I have several infomsgs put throughout the code below for troubleshooting purposes. They all fire except one; the very last one after the RUN SendEmail procedure. This isn't my first email BPM and all the others are working fine on the system. For some of this, I cut-and-pasted known working code to avoid typos. Nothing complex here. All variables are being populated fine (validated with infomsgs).
This is syncronously running. It's a pre-proc method directive. I've also tried making a post-proc method directive out of it and, while it runs, it also doesn't send an email.
Any thoughts?? TIA.
/* EMAIL ALERT CODE */
/* CHECKS AND MAKES SURE THERE IS AN APPROVER RESPONSE IN UPDATE */
FOR EACH TTPOAPVMSG WHERE TTPOAPVMSG.RowMod = 'U' AND TTPOAPVMSG.ApproverResponse <> ''.
IF AVAIL TTPOAPVMSG THEN DO:
/* FOR TESTING PURPOSES... */
{lib/PublishInfoMsg.i &InfoMsg = "'HELLO! ' + TTPOAPVMSG.APPROVERRESPONSE + ' ' + TTPOAPVMSG.MSGFROM + ' ' + TTPOAPVMSG.MSGTO "}
/* SET VARIABLES FOR ROUTINE AND EMAIL */
DEFINE VARIABLE vApprovalPersonName AS CHARACTER NO-UNDO.
DEFINE VARIABLE vApprovalPersonEmail AS CHARACTER NO-UNDO.
DEFINE VARIABLE vBuyerName AS CHARACTER NO-UNDO.
DEFINE VARIABLE vBuyerEmail AS CHARACTER NO-UNDO.
DEFINE VARIABLE vPONum AS CHARACTER NO-UNDO.
DEFINE VARIABLE vApproverResponse AS CHARACTER NO-UNDO.
/* SET THE PO# AND APPROVER RESPONSE (EITHER "APPROVED" OR "REJECTED") */
ASSIGN vPONum = STRING(TTPOAPVMSG.PONum).
ASSIGN vApproverResponse = TTPOAPVMSG.ApproverResponse.
/* GO GET THE EMAIL ADDRESSES FOR BOTH THE BUYER AND APPROVER */
/* BUYER FIRST: */
FIND FIRST PURAGENT WHERE PurAgent.Company = TTPOAPVMSG.Company AND PurAgent.BuyerID = TTPOAPVMSG.MsgFrom.
/* ONLY NEED FIRST NAME OF BUYER FOR EMAIL REPLY */
ASSIGN vBuyerName = RIGHT-TRIM(SUBSTRING(PURAGENT.Name,1,INDEX(PURAGENT.Name,' '))).
ASSIGN vBuyerEmail = PURAGENT.EMailAddress.
{lib/PublishInfoMsg.i &InfoMsg = "'BUYER EMAIL IS '+ vBuyerEmail + ' NAME IS: ' + vBuyerName + ' AND PO# IS ' + vPONum"}.
/* APPROVER NEXT: */
FIND FIRST PURAGENT WHERE PurAgent.Company = TTPOAPVMSG.Company AND PurAgent.BuyerID = TTPOAPVMSG.MsgTo.
ASSIGN vApprovalPersonName = PURAGENT.Name.
ASSIGN vApprovalPersonEmail = PURAGENT.EMailAddress.
{lib/PublishInfoMsg.i &InfoMsg = "'APPROVER EMAIL IS '+ vApprovalPersonEmail"}.
{lib/PublishInfoMsg.i &InfoMsg = "'APPROVER NAME IS '+ vApprovalPersonName"}.
/* ------------------------------------------------------------*/
/* WE HAVE EVERYTHING WE NEED NOW TO GENERATE EMAIL ALERT */
/* BEGIN EMAIL PROCESS */
/* ------------------------------------------------------------*/
/* BELOW ARE VARIABLES USED SPECIFICALLY FOR EMAIL */
DEFINE VARIABLE vFrom AS CHARACTER NO-UNDO.
DEFINE VARIABLE vTo AS CHARACTER NO-UNDO.
DEFINE VARIABLE vCC AS CHARACTER NO-UNDO.
DEFINE VARIABLE vSubject AS CHARACTER NO-UNDO.
DEFINE VARIABLE vBody AS CHARACTER NO-UNDO.
DEFINE VARIABLE hApproverEmailEx AS HANDLE NO-UNDO.
ASSIGN vFrom = 'epicor-alert@...'.
ASSIGN vTo = vBuyerEmail.
ASSIGN vCC = vApprovalPersonEmail.
ASSIGN vSubject = 'PO# ' + vPONum + ' APPROVAL REQUEST WAS ' + vApproverResponse.
ASSIGN vBody = CHR(13) + ' <<<<< THIS IS AN AUTOMATED MESSAGE -- DO NOT REPLY >>>>> ' + CHR(13) + CHR(13) + CHR(13) + vBuyerName + ',' + CHR(13) + CHR(13).
ASSIGN vBody = vBody + 'Your Approval Request for Purchase Order ' + vPONum + ' was ' + vApproverResponse + ' by ' + vApprovalPersonName + '.' + CHR(13) + CHR(13) + CHR(13).
{lib/PublishInfoMsg.i &InfoMsg = "'BODY IS '+ vBody"}.
{lib/PublishInfoMsg.i &InfoMsg = "'subject IS '+ vSubject"}.
RUN SendEmail IN hApproverEmailEx (
FALSE,
CUR-COMP,
vFrom,
vTo,
vCC,
vSubject,
vBody,
''
).
/* THIS INFOMSG BELOW NEVER FIRES!!! */
{lib/PublishInfoMsg.i &InfoMsg = "' AFTER EMAIL SEND '"}.
IF VALID-HANDLE(hApproverEmailEx) THEN DELETE PROCEDURE hApproverEmailEx.
LEAVE.
END.
END.
I see where you declared hApproverEmailEx but I don't see where you ever run BpmEmail.p to get a handle.
DOH!!
Thank you…. How did I overlook that? !!!Â
If you're going to Insights next week, please let me buy you a frosty adult beverage to repay you for your help!!Â
Thanks. It's always a comma, parenthesis, a period or something stupid like this that messes up code. :-)
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of jim_rogers@...
Sent: Monday, April 21, 2014 2:11 PM
To: vantage@yahoogroups.com
Subject: [Vantage] Re: BPM SendEmail doesn't work
Vic,
I see where you declared hApproverEmailEx but I don't see where you ever run BpmEmail.p to get a handle.
From: "whitenight922@..." <whitenight922@...>
To: vantage@yahoogroups.com
Sent: Friday, April 25, 2014 9:00 AM
Subject: [Vantage] Re: BPM SendEmail doesn't work
#ygrps-yiv-1623801989yiv7262710890 .ygrps-yiv-1623801989yiv7262710890ygrp-photo-title{
clear:both;font-size:smaller;height:15px;overflow:hidden;text-align:center;width:75px;}
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 div.ygrps-yiv-1623801989yiv7262710890ygrp-photo{
background-position:center;background-repeat:no-repeat;background-color:white;border:1px solid black;height:62px;width:62px;}
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 div.ygrps-yiv-1623801989yiv7262710890photo-title
a,
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 div.ygrps-yiv-1623801989yiv7262710890photo-title a:active,
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 div.ygrps-yiv-1623801989yiv7262710890photo-title a:hover,
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 div.ygrps-yiv-1623801989yiv7262710890photo-title a:visited {
text-decoration:none;}
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 div.ygrps-yiv-1623801989yiv7262710890attach-table div.ygrps-yiv-1623801989yiv7262710890attach-row {
clear:both;}
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 div.ygrps-yiv-1623801989yiv7262710890attach-table div.ygrps-yiv-1623801989yiv7262710890attach-row div {
float:left;}
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 p {
clear:both;padding:15px 0 3px 0;overflow:hidden;}
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 div.ygrps-yiv-1623801989yiv7262710890ygrp-file {
width:30px;}
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 div.ygrps-yiv-1623801989yiv7262710890attach-table div.ygrps-yiv-1623801989yiv7262710890attach-row div div a {
text-decoration:none;}
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 div.ygrps-yiv-1623801989yiv7262710890attach-table div.ygrps-yiv-1623801989yiv7262710890attach-row div div span {
font-weight:normal;}
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 div.ygrps-yiv-1623801989yiv7262710890ygrp-file-title {
font-weight:bold;}
#ygrps-yiv-1623801989
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 #ygrps-yiv-1623801989yiv7262710890 –
#ygrps-yiv-1623801989yiv7262710890ygrp-mkp {
border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 #ygrps-yiv-1623801989yiv7262710890ygrp-mkp hr {
border:1px solid #d8d8d8;}
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 #ygrps-yiv-1623801989yiv7262710890ygrp-mkp #ygrps-yiv-1623801989yiv7262710890hd {
color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 #ygrps-yiv-1623801989yiv7262710890ygrp-mkp #ygrps-yiv-1623801989yiv7262710890ads {
margin-bottom:10px;}
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 #ygrps-yiv-1623801989yiv7262710890ygrp-mkp .ygrps-yiv-1623801989yiv7262710890ad {
padding:0 0;}
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 #ygrps-yiv-1623801989yiv7262710890ygrp-mkp .ygrps-yiv-1623801989yiv7262710890ad p {
margin:0;}
#ygrps-yiv-1623801989 #ygrps-yiv-1623801989yiv7262710890 #ygrps-yiv-1623801989yiv7262710890ygrp-mkp .ygrps-yiv-1623801989yiv7262710890ad a {
color:#0000ff;text-decoration:none;}
#ygrps-yiv-1623801989
I haven't done one of these before, so this code is very useful, but I'm not sure where to put the "run BpmEmail.p" in the code. Other than that I was able to tweak the code posted here to create my own test for a BPM Email. Could someone tell me where that code goes? Thank you!