void sendmailtousers()
{
SysMailer mail ;
SysEmailParameters parameters ;
userGroupList userGroupListTO,userGroupListBCC;
BatchJob batchJob;
SysCompanyUserInfo sysCompanyUserInfo;
projtable projtable;
InteropPermission permission = new InteropPermission(InteropKind::ClrInterop);
emplid emplid ;
date scheduledate,dueenddate;
str header,mainbody,footer;
PAYFPrintPayrollBankFile PAYFPrintPayrollBankFile;
Counter linenum;
System.Net.Mail.MailMessage mailMessage;
System.Net.Mail.SmtpClient smtpClient;
System.Net.Mail.MailAddress mailAddressFrom;
System.Net.Mail.MailAddress mailAddressTo;
str strBody;
str strSMTPServer;
str strFileName,email;
FileIOPermission perm;
projid projid;
str sender,mailAddressTos;
void htmlbody()
{
date subdate;
str comp,event;
;
header = "" ;
mainbody = "";
footer = "";
comp = "Company AND SON'S LTD.";
event = "PAYROLL ALERTS";
header = strfmt("<p><strong><font color=#003399 face=Tahoma>PAYROLL REPORTS </font></strong> </p></br>"+
"<TABLE cellSpacing=0 cellPadding=1 width='100%' border=3>"+
"<tr bgColor=gray> "+
"<td align=center><font size=2 face=Tahoma>الرقم التسلسلي</td>"+//sn
"<td align=center><font size=2 face=Tahoma>الرقم العام</td>"+//emplid
"<td align=center><font size=2 face=Tahoma>الاسم</td>"+//name
"<td align=center><font size=2 face=Tahoma>الجنسية</td>"+//Nationality
"<td align=center><font size=2 face=Tahoma>العنوان</td>"+ //title
"<td align=center><font size=2 face=Tahoma>المشروع</td>"+//project
"<td align=center><font size=2 face=Tahoma>المنطقة</td>"+//region
"<td align=center><font size=2 face=Tahoma>الشهر</td>"+//Month
"<td align=center><font size=2 face=Tahoma>الحالة</td>"+//status
"</tr>");
while select PAYFPrintPayrollBankFile order by PAYFPrintPayrollBankFile.Dimension[2] ,PAYFPrintPayrollBankFile.EmplId where
PAYFPrintPayrollBankFile.TransferStatus == BankFileTransferStaus::NotTransfer
// && PAYFPrintPayrollBankFile.PAYFPeriodNumber == "PERD000005035"
{
linenum++;
if(linenum != 1 && projid != PAYFPrintPayrollBankFile.Dimension[2])
{
mainbody += strfmt("<tr bgColor=gray> <td height=10 colspan=9> "+" " +"</td></tr>" );
}
mainbody += strfmt("<TR ALIGN='CENTER'>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + num2str(linenum,3,0,0,0) + "</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + PAYFPrintPayrollBankFile.EmplId + "</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + PAYFPrintPayrollBankFile.name()+"</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + PAYFPrintPayrollBankFile.addressCountryRegionNationality()+ "</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + PAYFPrintPayrollBankFile.titleDescdription()+"</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + PAYFPrintPayrollBankFile.DescDim2()+ "</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + PAYFPrintPayrollBankFile.DescDim3()+"</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + date2str(PAYFCalculationPeriods::find(PAYFPrintPayrollBankFile.PAYFPeriodNumber,false).PAYFPeriodStartDate,123,0,4,2,4,4) +"</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + enum2str(PAYFPrintPayrollBankFile.TransferStatus) +"</TD>"+
"</TR>" );
projid = PAYFPrintPayrollBankFile.Dimension[2];
}
footer = strfmt( "</TABLE></br><font color=#cccccc size=2 face=Tahoma><p>_______________________________________________________________________ </p>"+
"</font><b><font color=#003399 face=Tahoma><p>Alert details<font color=#003399 size=2 face=Tahoma></font></p>"+
"</font></b><font color=#003399 size=2 face=Tahoma></font><font color=#cccccc size=2><p>"+
"<table border= 5 cellSpacing=1 cellPadding=3>"+
"<tbody>"+
"<tr> <td><p align=left><b><font size=2 face=Tahoma>Date:</font></p></td> <td><p><font face=Tahoma><font color=#003399 size=2>"+date2str(today(),123,2,4,3,4,4)+"</font></font></p></td></tr>"+
"<tr> <td><p align=left><b><font size=2><font face=Tahoma>Company:</font></font></p></td><td><font face=Tahoma><font color=#003399><font size=2> "+comp+" </font> </font></font></td></tr>"+
"<tr> <td><font face=Tahoma><b><font size=2 face=Tahoma>Event:</font></font></td><td><font face=Tahoma><font color=#003399 size=2 face=Tahoma>"+event+"</font></font></td></tr>"+
"</tbody> </table>") ;
}
void sendmail(str to)
{
mailMessage = new System.Net.Mail.MailMessage("ax.alertsender@alfahhad.com.sa",to);
mailmessage.set_Subject(strfmt("PAYROLL BANKFILE NOT TRANSFER ALERTS"));
strBody =header+mainbody+footer;
mailmessage.set_IsBodyHtml(true);
mailmessage.set_Body(strBody);
smtpClient.Send(mailmessage);
}
;
permission.assert();
parameters = SysEmailParameters::find();
mailAddressFrom = new System.Net.Mail.MailAddress("ax.alertsender@alfahhad.com.sa","@FAH878");
strSMTPServer = parameters.SMTPRelayServerName;
sender = "ax.alertsender@alfahhad.com.sa";
smtpClient = new System.Net.Mail.SmtpClient(strSMTPServer);
select * from BatchJob where BatchJob.Caption == "Bankfilealerts";
htmlbody();
/* Send Emails to user*/
if(linenum != 0)
{
while
select userGroupListTO
where userGroupListTO.GroupId == "Bnkfilalrt"
{
Email = "";
Email =SysUserInfo::find(userGroupListTO.UserId).Email;
sendmail(Email);
}
}
}
Download .xpo file
https://drive.google.com/file/d/0ByF76Avzw0r1TnlJUW9ZWm5WYkk/view?usp=sharing
{
SysMailer mail ;
SysEmailParameters parameters ;
userGroupList userGroupListTO,userGroupListBCC;
BatchJob batchJob;
SysCompanyUserInfo sysCompanyUserInfo;
projtable projtable;
InteropPermission permission = new InteropPermission(InteropKind::ClrInterop);
emplid emplid ;
date scheduledate,dueenddate;
str header,mainbody,footer;
PAYFPrintPayrollBankFile PAYFPrintPayrollBankFile;
Counter linenum;
System.Net.Mail.MailMessage mailMessage;
System.Net.Mail.SmtpClient smtpClient;
System.Net.Mail.MailAddress mailAddressFrom;
System.Net.Mail.MailAddress mailAddressTo;
str strBody;
str strSMTPServer;
str strFileName,email;
FileIOPermission perm;
projid projid;
str sender,mailAddressTos;
void htmlbody()
{
date subdate;
str comp,event;
;
header = "" ;
mainbody = "";
footer = "";
comp = "Company AND SON'S LTD.";
event = "PAYROLL ALERTS";
header = strfmt("<p><strong><font color=#003399 face=Tahoma>PAYROLL REPORTS </font></strong> </p></br>"+
"<TABLE cellSpacing=0 cellPadding=1 width='100%' border=3>"+
"<tr bgColor=gray> "+
"<td align=center><font size=2 face=Tahoma>الرقم التسلسلي</td>"+//sn
"<td align=center><font size=2 face=Tahoma>الرقم العام</td>"+//emplid
"<td align=center><font size=2 face=Tahoma>الاسم</td>"+//name
"<td align=center><font size=2 face=Tahoma>الجنسية</td>"+//Nationality
"<td align=center><font size=2 face=Tahoma>العنوان</td>"+ //title
"<td align=center><font size=2 face=Tahoma>المشروع</td>"+//project
"<td align=center><font size=2 face=Tahoma>المنطقة</td>"+//region
"<td align=center><font size=2 face=Tahoma>الشهر</td>"+//Month
"<td align=center><font size=2 face=Tahoma>الحالة</td>"+//status
"</tr>");
while select PAYFPrintPayrollBankFile order by PAYFPrintPayrollBankFile.Dimension[2] ,PAYFPrintPayrollBankFile.EmplId where
PAYFPrintPayrollBankFile.TransferStatus == BankFileTransferStaus::NotTransfer
// && PAYFPrintPayrollBankFile.PAYFPeriodNumber == "PERD000005035"
{
linenum++;
if(linenum != 1 && projid != PAYFPrintPayrollBankFile.Dimension[2])
{
mainbody += strfmt("<tr bgColor=gray> <td height=10 colspan=9> "+" " +"</td></tr>" );
}
mainbody += strfmt("<TR ALIGN='CENTER'>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + num2str(linenum,3,0,0,0) + "</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + PAYFPrintPayrollBankFile.EmplId + "</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + PAYFPrintPayrollBankFile.name()+"</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + PAYFPrintPayrollBankFile.addressCountryRegionNationality()+ "</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + PAYFPrintPayrollBankFile.titleDescdription()+"</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + PAYFPrintPayrollBankFile.DescDim2()+ "</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + PAYFPrintPayrollBankFile.DescDim3()+"</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + date2str(PAYFCalculationPeriods::find(PAYFPrintPayrollBankFile.PAYFPeriodNumber,false).PAYFPeriodStartDate,123,0,4,2,4,4) +"</TD>"+
"<TD><font color=#003399 size=2 face=Tahoma>" + enum2str(PAYFPrintPayrollBankFile.TransferStatus) +"</TD>"+
"</TR>" );
projid = PAYFPrintPayrollBankFile.Dimension[2];
}
footer = strfmt( "</TABLE></br><font color=#cccccc size=2 face=Tahoma><p>_______________________________________________________________________ </p>"+
"</font><b><font color=#003399 face=Tahoma><p>Alert details<font color=#003399 size=2 face=Tahoma></font></p>"+
"</font></b><font color=#003399 size=2 face=Tahoma></font><font color=#cccccc size=2><p>"+
"<table border= 5 cellSpacing=1 cellPadding=3>"+
"<tbody>"+
"<tr> <td><p align=left><b><font size=2 face=Tahoma>Date:</font></p></td> <td><p><font face=Tahoma><font color=#003399 size=2>"+date2str(today(),123,2,4,3,4,4)+"</font></font></p></td></tr>"+
"<tr> <td><p align=left><b><font size=2><font face=Tahoma>Company:</font></font></p></td><td><font face=Tahoma><font color=#003399><font size=2> "+comp+" </font> </font></font></td></tr>"+
"<tr> <td><font face=Tahoma><b><font size=2 face=Tahoma>Event:</font></font></td><td><font face=Tahoma><font color=#003399 size=2 face=Tahoma>"+event+"</font></font></td></tr>"+
"</tbody> </table>") ;
}
void sendmail(str to)
{
mailMessage = new System.Net.Mail.MailMessage("ax.alertsender@alfahhad.com.sa",to);
mailmessage.set_Subject(strfmt("PAYROLL BANKFILE NOT TRANSFER ALERTS"));
strBody =header+mainbody+footer;
mailmessage.set_IsBodyHtml(true);
mailmessage.set_Body(strBody);
smtpClient.Send(mailmessage);
}
;
permission.assert();
parameters = SysEmailParameters::find();
mailAddressFrom = new System.Net.Mail.MailAddress("ax.alertsender@alfahhad.com.sa","@FAH878");
strSMTPServer = parameters.SMTPRelayServerName;
sender = "ax.alertsender@alfahhad.com.sa";
smtpClient = new System.Net.Mail.SmtpClient(strSMTPServer);
select * from BatchJob where BatchJob.Caption == "Bankfilealerts";
htmlbody();
/* Send Emails to user*/
if(linenum != 0)
{
while
select userGroupListTO
where userGroupListTO.GroupId == "Bnkfilalrt"
{
Email = "";
Email =SysUserInfo::find(userGroupListTO.UserId).Email;
sendmail(Email);
}
}
}
Download .xpo file
https://drive.google.com/file/d/0ByF76Avzw0r1TnlJUW9ZWm5WYkk/view?usp=sharing
No comments:
Post a Comment