// Automatic Mail From SMTP server and attachments
clicked()
SrsReportRunController controller = new SrsReportRunController();
PurchPurchaseOrderContract purchPurchaseOrderContract;
Args args = new Args();
SrsReportRunImpl srsReportRun;
VendPurchOrderJour vendPurchJour;
SrsPrintMgmtExecutionInfo printMgmtExecutionInfo;
ReportName reportName = "PurchPurchaseOrder.Report";
str email;
Set permissionSet;
int i;
System.Exception e;
str 100 fileName,invoiceSubject;
SysEmailMessageTable message;
Dialog dialog;
DialogField dfFileName;
str mailServer;
int mailServerPort;
str testmail = "admin@cbizol.com";
System.Net.Mail.SmtpClient mailClient;
System.Net.Mail.MailMessage mailMessage;
System.Net.Mail.MailAddress mailFrom;
System.Net.Mail.MailAddress mailTo;
System.Net.Mail.MailAddressCollection mailToCollection;
System.Net.Mail.MailAddressCollection mailCCCollection;
System.Net.Mail.AttachmentCollection mailAttachementCollection;
System.Net.Mail.Attachment mailAttachment;
;
dialog = new Dialog("Pick location");
dfFileName = dialog.addField(extendedTypeStr(FilePath));
dialog.run();
permissionSet = new Set(Types::Class);
permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
permissionSet.add(new FileIOPermission(filename, 'rw'));
CodeAccessPermission::assertMultiple(permissionSet);
mailServer = SysEmaiLParameters::find(false).SMTPRelayServerName;
mailServerPort = SysEmaiLParameters::find(false).SMTPPortNumber;
mailClient = new System.Net.Mail.SmtpClient(mailServer, mailServerPort);
message = SysEmailMessageTable::find("Alerts", "en-us");
mailFrom = new System.Net.Mail.MailAddress(testmail);
mailTo = new System.Net.Mail.MailAddress(testmail);//strLTrim(strRTrim(custTable.email())));
mailMessage = new System.Net.Mail.MailMessage(mailFrom, mailTo);
mailToCollection = mailMessage.get_To();
mailMessage.set_Priority(System.Net.Mail.MailPriority::High);
mailMessage.set_Subject(invoiceSubject);
mailAttachementCollection = mailMessage.get_Attachments();
select firstOnly vendPurchJour;
args.record(vendPurchJour);
fileName = strfmt("%1\\PurchPurchaseOrder %2.pdf",dfFileName.value(), vendPurchJour.PurchOrderDocNum);
controller.parmReportName(reportName);
purchPurchaseOrderContract = controller.parmReportContract().parmRdpContract();
purchPurchaseOrderContract.parmRecordId(vendPurchJour.RecId);
purchPurchaseOrderContract.parmDocumentTitle("test");//(custInvoiceJour.RecId); // Record id must be passed otherwise the report will be empty
controller.parmArgs(args);
srsReportRun = controller.parmReportRun() as SrsReportRunImpl;
controller.parmReportRun(srsReportRun);
controller.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
controller.parmReportContract().parmPrintSettings().overwriteFile(true);
controller.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
controller.parmReportContract().parmPrintSettings().fileName(fileName);
controller.runReport();
mailAttachment = new System.Net.Mail.Attachment(fileName);
mailAttachementCollection.Add(mailAttachment);
// get the next selected record
vendPurchJour = VendPurchOrderJour_ds.getNext();
mailClient.SendAsyncCancel();
// mailClient.Send(mailMessage);
mailMessage.Dispose();
CodeAccessPermission::revertAssert();
clicked()
SrsReportRunController controller = new SrsReportRunController();
PurchPurchaseOrderContract purchPurchaseOrderContract;
Args args = new Args();
SrsReportRunImpl srsReportRun;
VendPurchOrderJour vendPurchJour;
SrsPrintMgmtExecutionInfo printMgmtExecutionInfo;
ReportName reportName = "PurchPurchaseOrder.Report";
str email;
Set permissionSet;
int i;
System.Exception e;
str 100 fileName,invoiceSubject;
SysEmailMessageTable message;
Dialog dialog;
DialogField dfFileName;
str mailServer;
int mailServerPort;
str testmail = "admin@cbizol.com";
System.Net.Mail.SmtpClient mailClient;
System.Net.Mail.MailMessage mailMessage;
System.Net.Mail.MailAddress mailFrom;
System.Net.Mail.MailAddress mailTo;
System.Net.Mail.MailAddressCollection mailToCollection;
System.Net.Mail.MailAddressCollection mailCCCollection;
System.Net.Mail.AttachmentCollection mailAttachementCollection;
System.Net.Mail.Attachment mailAttachment;
;
dialog = new Dialog("Pick location");
dfFileName = dialog.addField(extendedTypeStr(FilePath));
dialog.run();
permissionSet = new Set(Types::Class);
permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
permissionSet.add(new FileIOPermission(filename, 'rw'));
CodeAccessPermission::assertMultiple(permissionSet);
mailServer = SysEmaiLParameters::find(false).SMTPRelayServerName;
mailServerPort = SysEmaiLParameters::find(false).SMTPPortNumber;
mailClient = new System.Net.Mail.SmtpClient(mailServer, mailServerPort);
message = SysEmailMessageTable::find("Alerts", "en-us");
mailFrom = new System.Net.Mail.MailAddress(testmail);
mailTo = new System.Net.Mail.MailAddress(testmail);//strLTrim(strRTrim(custTable.email())));
mailMessage = new System.Net.Mail.MailMessage(mailFrom, mailTo);
mailToCollection = mailMessage.get_To();
mailMessage.set_Priority(System.Net.Mail.MailPriority::High);
mailMessage.set_Subject(invoiceSubject);
mailAttachementCollection = mailMessage.get_Attachments();
select firstOnly vendPurchJour;
args.record(vendPurchJour);
fileName = strfmt("%1\\PurchPurchaseOrder %2.pdf",dfFileName.value(), vendPurchJour.PurchOrderDocNum);
controller.parmReportName(reportName);
purchPurchaseOrderContract = controller.parmReportContract().parmRdpContract();
purchPurchaseOrderContract.parmRecordId(vendPurchJour.RecId);
purchPurchaseOrderContract.parmDocumentTitle("test");//(custInvoiceJour.RecId); // Record id must be passed otherwise the report will be empty
controller.parmArgs(args);
srsReportRun = controller.parmReportRun() as SrsReportRunImpl;
controller.parmReportRun(srsReportRun);
controller.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
controller.parmReportContract().parmPrintSettings().overwriteFile(true);
controller.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
controller.parmReportContract().parmPrintSettings().fileName(fileName);
controller.runReport();
mailAttachment = new System.Net.Mail.Attachment(fileName);
mailAttachementCollection.Add(mailAttachment);
// get the next selected record
vendPurchJour = VendPurchOrderJour_ds.getNext();
mailClient.SendAsyncCancel();
// mailClient.Send(mailMessage);
mailMessage.Dispose();
CodeAccessPermission::revertAssert();
No comments:
Post a Comment