Send Email From ProcessScheduler Processes
Function SendEmailFromProcessScheduler(&ProcessType As string, &ProcessName As string, &sEmailSubject As string, &sEmailBody As string)
Local SQL &Email_ID_SQL;
Local string &EmaiId, &Email_Ids;
&Email_Ids = "";
&Email_ID_SQL = CreateSQL("SELECT A.EMAILID FROM PSUSEREMAIL A, PS_PRCSDEFNNOTIFY B WHERE A.OPRID = B.DISTID AND B.PRCSTYPE =:1 AND B.PRCSNAME = :2 AND B.DISTIDTYPE = '2' AND A.EMAILTYPE = 'BUS' union SELECT A.EMAILID FROM PSUSEREMAIL A, PS_PRCSDEFNNOTIFY B, PS_ROLEUSER_VW C WHERE A.OPRID = C.ROLEUSER AND C.ROLENAME = B.DISTID AND B.PRCSTYPE =:1 AND B.PRCSNAME = :2 AND B.DISTIDTYPE = '3' AND A.EMAILTYPE = 'BUS' ", (&ProcessType, &ProcessName);
While &Email_ID_SQL.Fetch(&EmaiId)
If &Email_Ids = "" Then
&Email_Ids = &EmaiId
Else
&Email_Ids = &Email_Ids | ";" | &EmaiId
End-If
End-While;
&Email_ID_SQL.Close();
&nFlag = 0;
&strCC = "";
&strBCC = "";
If All(&Email_Ids) Then
SendMail(&nFlag, &Email_Ids, &strCC, &strBCC, &sEmailSubject, &sEmailBody);
Else
MessageBox(0, "", 0, 0, "*** NO USER NOTIFICATION SETUP ***");
End-If;
End-Function;
No comments:
Post a Comment