Sending multiple attachments in BC

AitorEG
Member Posts: 342
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
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
Best Answer
-
Not without a customization. This works for us in BC15 OnPrem - for SaaS you probably have to read into a stream rather than a file.
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;
}Kyle Hardin - ArcherPoint5
Answers
-
Not without a customization. This works for us in BC15 OnPrem - for SaaS you probably have to read into a stream rather than a file.
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;
}Kyle Hardin - ArcherPoint5 -
Thanks for your ansewer Kyle. The development is quite simple, but I was expecting to be able to do that with the standarts functionality. The chance of adding more than one report in the sales report selection table has given me to understand that may be it will be
Thank you again!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions