Reputation: 39
I'm trying to send Mails using a PXAction in Acumatica and untill now i'm able to send mails up to the number of columns i select from a grid i just don't know how to attach the PDF to the Message, there is something like AddAttachment("report.pdf", buffer.ToArray()); but i don't really know how to specify the report (as a PDF) that is going to be attached
Upvotes: 0
Views: 361
Reputation: 1056
using System.IO;
Report report = PXReportTools.LoadReport("AP642010", null);
if (report == null) return;
parameters["StartCheckNbr"] = payment.ExtRefNbr;
PXReportTools.InitReportParameters(report, parameters, PXSettingProvider.Instance.Default);
ReportNode repNode = ReportProcessor.ProcessReport(report);
var streamMgr = new StreamManager();
string format = ReportProcessor.FilterPdf;
var renderFilter = ReportProcessor.GetRenderer(format);
renderFilter.Render(repNode, null, streamMgr);
streamMgr.MainStream.Flush();
streamMgr.MainStream.Seek(0, System.IO.SeekOrigin.Begin);
string file = @"C:\Temp\AP642010.pdf";
string tempPath = Path.GetTempPath();
string path = Path.Combine(tempPath, Path.GetFileName(file));
var mystream = new MemoryStream(System.IO.File.ReadAllBytes(path));
sender.AddAttachment(path, mystream.ToArray());`
Upvotes: 1