Friday, 17 August 2018
Thursday, 2 August 2018
send mail after submitting PurchRFQ with attachment
Send mail after submitting PurchRFQ with attachment
PurchRFQFormLetter - Main
pass the table(vendRFQJourLoc) to the custom class to save and send email
_sendEmailRFQ is the custom class
while select
{ _sendEmailRFQ.runAndSaveSSRSReport(_vendRFQJourLoc); _sendEmailRFQ.RFQEmail(_vendRFQJourLoc); }
..............................................................................................................................................................................................
class K_SendEmailRFQ { }
public void deleteReportFile(str _ReportPath) { str ReportPath = _ReportPath; if(!ReportPath) warning("No file in local to remove"); else WinAPI::deleteFile(@ReportPath); }
./////
public void RFQEmail(VendRFQJour _vendRFQJour) { #define.HTML1(" ") #define.HTML2("") SysEmailParameters parameters = SysEmailParameters::find(); SMTPRelayServerName relayServer; SMTPPortNumber portNumber; SMTPUserName userName; SMTPPassword password; Str subject,body; InteropPermission interopPermission; SysMailer mailer; System.Exception e; FilePath attachFileExcel,attachFileInvoice,attachFileCommon; VendTable vendTable; PurchTable purchTableLoc; str email,Rfqid; FilePath invPath; FilenameOpen _InvoicePath; SysEmailMessageTable message; Notes msgbody ; LogisticsElectronicAddress LogisticsElectronicAddress; LogisticsLocation LogisticsLocation; DirPartyLocation dirPartyLocation; PurchRFQVendLink purchRFQVendLink; // VendRFQJour _vendRFQJour; str emailAddress; RecId recId; str Name; SysUserInfo sysUserInfo; //alle 2192018 msk strt SysEmailTable sysEmailTable; Map mappings = new Map(Types::String, Types::String); //alle 2192018 msk end ; _InvoicePath = this.runAndSaveSSRSReport(_vendRFQJour); select Email from sysUserInfo where sysUserInfo.Id == curUserId(); Name = sysUserInfo.Email; Rfqid = _vendRFQJour.RFQId; while select vendTable where vendTable.AccountNum == _vendRFQJour.VendAccount join dirPartyLocation where vendTable.Party == dirPartyLocation.Party join logisticsElectronicAddress where logisticsElectronicAddress.Location == dirPartyLocation.Location && logisticsElectronicAddress.IsPrimary == NoYes::Yes && logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Email { email = LogisticsElectronicAddress.Locator; if (parameters.SMTPRelayServerName) relayServer = parameters.SMTPRelayServerName; else relayServer = parameters.SMTPServerIPAddress; portNumber = parameters.SMTPPortNumber; userName = parameters.SMTPUserName; password = SysEmailParameters::password(); body += strFmt(' <b> Please find attached our Request for Quote number '+Rfqid+'') + "<br/><br/>"; sysEmailTable = SysEmailTable::find('RFQ'); message = SysEmailMessageTable::find(sysEmailTable.EmailId, sysEmailTable.DefaultLanguage); subject = message.Subject; msgbody = message.Mail; CodeAccessPermission::revertAssert(); try { interopPermission = new InteropPermission(InteropKind::ComInterop); interopPermission.assert(); mailer = new SysMailer(); mailer.SMTPRelayServer(relayServer,portNumber,userName,password, parameters.NTLM); mailer.fromAddress("ax@scgroup.global"); //(SysUserInfo::find().Email); mailer.tos().appendAddress(email); //_defEmail); mailer.ccs().appendAddress(Name); mailer.attachments().add(_InvoicePath); mailer.subject(subject); mailer.htmlBody(body+msgbody); // mailer.htmlBody(body); mailer.sendMail(); CodeAccessPermission::revertAssert(); info("Email sent successfully "); } catch (Exception::CLRError) { e = ClrInterop::getLastException(); while (e) { info(e.get_Message()); e = e.get_InnerException(); } CodeAccessPermission::revertAssert(); info ("error"); } //mappings.insert('RFQNumber', _vendRFQJour.RFQId); //sysEmailTable = SysEmailTable::find('RFQ'); //SysEmailTable::sendMail(sysEmailTable.EmailId, //'en-au', // Chosen language //email ,//'sivakumar@x.com', // Who you're sending the email to //mappings, // Your variable mappings //_InvoicePath, // Location of file attachment (server/client matters) or none //"" , // XML if you're using XSLT //false , // Traceable or not? //'admin', // Sending user //false); // Use retries? } WinAPI::deleteFile(_InvoicePath); //WinAPI::deleteFile(_commonPath); //WinAPI::deleteFile(_ExcelPath); WinAPI::deleteFile(attachFileExcel); WinAPI::deleteFile(attachFileInvoice); WinAPI::deleteFile(attachFileCommon); }
PurchRFQFormLetter - Main
pass the table(vendRFQJourLoc) to the custom class to save and send email
_sendEmailRFQ is the custom class
while select
vendRFQJourLoc where
vendRFQJourLoc.RFQCaseId == PurchRFQCaseTable::findRecId(args.record().RecId).RFQCaseId { _sendEmailRFQ.runAndSaveSSRSReport(_vendRFQJourLoc); _sendEmailRFQ.RFQEmail(_vendRFQJourLoc); }
..............................................................................................................................................................................................
class K_SendEmailRFQ { }
public void deleteReportFile(str _ReportPath) { str ReportPath = _ReportPath; if(!ReportPath) warning("No file in local to remove"); else WinAPI::deleteFile(@ReportPath); }
./////
public void RFQEmail(VendRFQJour _vendRFQJour) { #define.HTML1(" ") #define.HTML2("") SysEmailParameters parameters = SysEmailParameters::find(); SMTPRelayServerName relayServer; SMTPPortNumber portNumber; SMTPUserName userName; SMTPPassword password; Str subject,body; InteropPermission interopPermission; SysMailer mailer; System.Exception e; FilePath attachFileExcel,attachFileInvoice,attachFileCommon; VendTable vendTable; PurchTable purchTableLoc; str email,Rfqid; FilePath invPath; FilenameOpen _InvoicePath; SysEmailMessageTable message; Notes msgbody ; LogisticsElectronicAddress LogisticsElectronicAddress; LogisticsLocation LogisticsLocation; DirPartyLocation dirPartyLocation; PurchRFQVendLink purchRFQVendLink; // VendRFQJour _vendRFQJour; str emailAddress; RecId recId; str Name; SysUserInfo sysUserInfo; //alle 2192018 msk strt SysEmailTable sysEmailTable; Map mappings = new Map(Types::String, Types::String); //alle 2192018 msk end ; _InvoicePath = this.runAndSaveSSRSReport(_vendRFQJour); select Email from sysUserInfo where sysUserInfo.Id == curUserId(); Name = sysUserInfo.Email; Rfqid = _vendRFQJour.RFQId; while select vendTable where vendTable.AccountNum == _vendRFQJour.VendAccount join dirPartyLocation where vendTable.Party == dirPartyLocation.Party join logisticsElectronicAddress where logisticsElectronicAddress.Location == dirPartyLocation.Location && logisticsElectronicAddress.IsPrimary == NoYes::Yes && logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Email { email = LogisticsElectronicAddress.Locator; if (parameters.SMTPRelayServerName) relayServer = parameters.SMTPRelayServerName; else relayServer = parameters.SMTPServerIPAddress; portNumber = parameters.SMTPPortNumber; userName = parameters.SMTPUserName; password = SysEmailParameters::password(); body += strFmt(' <b> Please find attached our Request for Quote number '+Rfqid+'') + "<br/><br/>"; sysEmailTable = SysEmailTable::find('RFQ'); message = SysEmailMessageTable::find(sysEmailTable.EmailId, sysEmailTable.DefaultLanguage); subject = message.Subject; msgbody = message.Mail; CodeAccessPermission::revertAssert(); try { interopPermission = new InteropPermission(InteropKind::ComInterop); interopPermission.assert(); mailer = new SysMailer(); mailer.SMTPRelayServer(relayServer,portNumber,userName,password, parameters.NTLM); mailer.fromAddress("ax@scgroup.global"); //(SysUserInfo::find().Email); mailer.tos().appendAddress(email); //_defEmail); mailer.ccs().appendAddress(Name); mailer.attachments().add(_InvoicePath); mailer.subject(subject); mailer.htmlBody(body+msgbody); // mailer.htmlBody(body); mailer.sendMail(); CodeAccessPermission::revertAssert(); info("Email sent successfully "); } catch (Exception::CLRError) { e = ClrInterop::getLastException(); while (e) { info(e.get_Message()); e = e.get_InnerException(); } CodeAccessPermission::revertAssert(); info ("error"); } //mappings.insert('RFQNumber', _vendRFQJour.RFQId); //sysEmailTable = SysEmailTable::find('RFQ'); //SysEmailTable::sendMail(sysEmailTable.EmailId, //'en-au', // Chosen language //email ,//'sivakumar@x.com', // Who you're sending the email to //mappings, // Your variable mappings //_InvoicePath, // Location of file attachment (server/client matters) or none //"" , // XML if you're using XSLT //false , // Traceable or not? //'admin', // Sending user //false); // Use retries? } WinAPI::deleteFile(_InvoicePath); //WinAPI::deleteFile(_commonPath); //WinAPI::deleteFile(_ExcelPath); WinAPI::deleteFile(attachFileExcel); WinAPI::deleteFile(attachFileInvoice); WinAPI::deleteFile(attachFileCommon); }
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
public str runAndSaveSSRSReport(VendRFQJour _vendRFQJourLoc)
{
SrsReportRunController ssrsController = new SrsReportRunController();
PurchRFQSendContract Contract = new PurchRFQSendContract();
SRSPrintDestinationSettings printerSettings;
//VendRFQJour _vendRFQJourLoc;
str ReportPath;
/*select firstOnly _vendRFQJourLoc
order by _vendRFQJourLoc.createdDateTime DESC
where _vendRFQJourLoc.RFQCaseId == _caseTable.RFQCaseId;*/
ReportPath = "C:\\SendRFQReport\\" + _vendRFQJourLoc.RFQId +".pdf";
ssrsController.parmReportName(ssrsReportStr(RFQSend, Report));
ssrsController.parmExecutionMode(SysOperationExecutionMode::Synchronous);
ssrsController.parmShowDialog(false);
Contract.parmPurchInternalRFQId(_vendRFQJourLoc.InternalRFQId);
Contract.parmDocumentTitle('Request for Quotation');
ssrsController.parmReportContract().parmRdpContract(Contract);
printerSettings = ssrsController.parmReportContract().parmPrintSettings();
printerSettings.printMediumType(SRSPrintMediumType::File);
printerSettings.fileFormat(SRSReportFileFormat::PDF);
printerSettings.overwriteFile(true);
printerSettings.fileName(@ReportPath);
ssrsController.runReport();
return ReportPath;
}
..................................................................................................................................................................
public static void main(Args _args)
{
PurchRFQCaseTable _vendRFQJourLo;
FilenameOpen attachmentFilename;
Alle_SendEmailRFQ sendEmailPOConfirmation;
sendEmailPOConfirmation = new K_SendEmailRFQ();
}
Subscribe to:
Posts (Atom)