trigger OnAction()
var
TxtDefaultCCMailList: List of [Text];
TxtDefaultBCCMailList: List of [Text];
TxtRecipientsList: List of [Text];
AttachmentTempBlob: Codeunit /Temp Blob/;
AttachmentInStream: InStream;
AttachmentOutStream: OutStream;
FileMgt: Codeunit /File Management/;
SalesInvoiceHdr: Record /Sales Invoice Header/;
RecRef: RecordRef;
begin
GetSalespersonEmail();
GetCustomerEmail();
if (SalespersonEmail <> '') and (CustomerEmail <> '') then begin
TxtRecipientsList.Add(CustomerEmail);
TxtDefaultCCMailList.Add(SalespersonEmail);
EmailMsg.Create(TxtRecipientsList, 'Thank you for your purchase!', 'Attached is your receipt. Please keep for your records.', false, TxtDefaultCCMailList, TxtDefaultBCCMailList);
AttachmentTempBlob.CreateOutStream(AttachmentOutStream);
SalesInvoiceHdr.Reset();
SalesInvoiceHdr.SetFilter(/No./, '=%1', Rec./Invoice Document No./);
if SalesInvoiceHdr.FindFirst() then begin
RecRef.GetTable(SalesInvoiceHdr);
Report.SaveAs(Report::/DCH Sales Invoice Report/, '', ReportFormat::Pdf, AttachmentOutStream, RecRef);
AttachmentTempBlob.CreateInStream(AttachmentInStream);
EmailMsg.AddAttachment(Rec./Invoice Document No./ + '.pdf', 'PDF', AttachmentInStream);
EmailObj.Send(EmailMsg, Enum::/Email Scenario/::Default);
Message('Message sent!');
end;
end;
end;
var
EmailObj: Codeunit Email;
EmailMsg: Codeunit /Email Message/;
SalespersonEmail: Text[80];
CustomerEmail: Text[80];