AlexTheDroog
New Member
I had the following query working with the "first" result showing up. The issue is there can be multiple rows returned. I was trying to concatenate each row (just 1 field) into a comma separated character variable and put it in the email body. The code complies but I never get an email. This code is fired in a BMP in Epicor 9.
Code:
define query email
for ttRMAHead FIELDS(Company RMANum),
SerialNo FIELDS(SerialNumber RMANum).
Define variable SN as character no-undo.
OPEN QUERY email for each ttRMAHead no-lock
where ttRMAHead.Company = cur-comp,
each SerialNo no-lock
outer-join where ( ttRMAHead.Company = SerialNo.Company and ttRMAHead.RMANum = SerialNo.RMANum).
SN = SN + SerialNo.SerialNumber + ", ".
repeat:
GET NEXT email NO-LOCK.
IF NOT AVAILABLE SerialNo THEN LEAVE.
if available SerialNo then do:
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 hEmailEx as handle no-undo.
run Bpm/BpmEmail.p persistent set hEmailEx.
assign vFrom = 'RAM-Delete@xxx.com'.
vTo = 'me@xxx.com'.
vSubject = vSubject + 'RMA ' + string(ttRMAHead.RMANum) + ' containing Serial Numbers was deleted. '.
vBody = vBody + 'RMA ' + string(ttRMAHead.RMANum) + ' containing SN: ' + string(SN) + ' was deleted. The ADBook needs to be reviewed and possiably corrected.'.
run SendEmail in hEmailEx (
false,
CUR-COMP,
vFrom,
vTo,
vCC,
vSubject,
vBody,
""
).
if valid-handle(hEmailEx) then delete procedure hEmailEx.
leave.
end.
end.
Last edited by a moderator: