Hi everyone,
From a posted sales invoice, I need to send to the customer another report, apart from the invoice itself. In the sales report selection page, I added another report as attachment.
I receive both documents, but in different mails. is it possible to send all the selected report into the same e-mail?
Thank you all
0
Answers
codeunit 50141 "ARC Codeunit 260 Subscribers"
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Document-Mailing", 'OnBeforeSendEmail', '', true, true)]
local procedure OnBeforeSendEmail(var TempEmailItem: Record "Email Item" temporary; var IsFromPostedDoc: Boolean; var PostedDocNo: Code[20]; var HideDialog: Boolean; var ReportUsage: Integer)
var
CKSSetup: Record "ARC CKS Setup";
FileManagement: Codeunit "File Management";
ServerFile: Text;
ReportUsageOption: Option "S.Quote","S.Order","S.Invoice","S.Cr.Memo","S.Test","P.Quote","P.Order","P.Invoice","P.Cr.Memo","P.Receipt","P.Ret.Shpt.","P.Test","B.Stmt","B.Recon.Test","B.Check",Reminder,"Fin.Charge","Rem.Test","F.C.Test","Prod.Order","S.Blanket","P.Blanket",M1,M2,M3,M4,Inv1,Inv2,Inv3,"SM.Quote","SM.Order","SM.Invoice","SM.Credit Memo","SM.Contract Quote","SM.Contract","SM.Test","S.Return","P.Return","S.Shipment","S.Ret.Rcpt.","S.Work Order","Invt.Period Test","SM.Shipment","S.Test Prepmt.","P.Test Prepmt.","S.Arch.Quote","S.Arch.Order","P.Arch.Quote","P.Arch.Order","S.Arch.Return","P.Arch.Return","Asm.Order","P.Asm.Order","S.Order Pick Instruction",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"P.V.Remit.","C.Statement","V.Remittance",JQ,"S.Invoice Draft","Pro Forma S. Invoice","S.Arch.Blanket","P.Arch.Blanket","Phys.Invt.Order Test","Phys.Invt.Order","P.Phys.Invt.Order","Phys.Invt.Rec.","P.Phys.Invt.Rec.";
begin
if ReportUsage = ReportUsageOption::"S.Invoice" then begin
CKSSetup.Get();
if CKSSetup."S.Invoice Terms and Conditions".HasValue() then begin
ServerFile := FileManagement.ServerTempFileName('.pdf');
CKSSetup."S.Invoice Terms and Conditions".ExportFile(ServerFile);
if File.Exists(ServerFile) then begin
TempEmailItem."Attachment File Path 2" := CopyStr(ServerFile, 1, MaxStrLen(TempEmailItem."Attachment File Path 2"));
TempEmailItem."Attachment Name 2" := 'Terms and Conditions.pdf';
end;
end;
end;
end;
}
Thank you again!