/* POForApprovalEmail */
define variable vapprov as character no-undo.
define variable vbuyer as character no-undo.
for each ttPOHeader where ttPOHeader.ApprovalStatus = 'P'.
if avail ttPOHeader then do:
Find first PurAgent where PurAgent.Company = ttPOHeader.Company and PurAgent.BuyerID = ttPOHeader.BuyerID.
assign vapprov = PurAgent.ApprovalPerson.
Find first PurAgent where PurAgent.Company = ttPOHeader.Company and PurAgent.BuyerID = vapprov.
assign vapprov = PurAgent.EMailAddress.
Find first PurAgent where PurAgent.Company = ttPOHeader.Company and PurAgent.BuyerID = ttPOHeader.BuyerID.
assign vbuyer = PurAgent.EmailAddress.
if vapprov <> '' 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 = vbuyer.
assign vTo = vapprov.
assign vCC = ''.
assign vSubject = vSubject + 'Purchase Order ' + string(ttPOHeader.PONUM) + ' needs approval'.
assign vBody = vBody + 'The above purchase order number requires approval'.
run SendEmail in hEmailEx (false,CUR-COMP,vFrom,vTo,vCC,vSubject,vBody,"").
if valid-handle(hEmailEx) then delete procedure hEmailEx.
leave.
end.
end.
end.