(Q1) I would like to know every time an email has been sent correctly, how can I do?

There are two solutions.

The first is to subscribe to this event:

    codeunit 18122024 "EOS Adv Mail Routines"

    <summary>This event is raised at the end of standard email sending process.</summary>
    <param name="AdvDocRequest">Current Request</param>
    <param name="AdvDocDocuments">Current Request Document</param>
    [IntegrationEvent(false, false)]
    procedure OnAfterSendMail(AdvDocRequest: Record "EOS AdvDoc Request"; AdvDocDocuments: Record "EOS AdvDoc Documents")
    begin
    end;

This event is raised only if the sending of the e-mail is successful (i.e. no exception is raised in the send).

The second solution is to hook into this event and analyze the result saved in the “Status” field for each docs, in the case of multiple submission, or request, in the case of single mail.

codeunit 18122025 "EOS Adv Mail Processing"
    /// <summary>This event is executed after the request processing and after the transaction commit.</summary>
    /// <param name="AdvDocRequest">Processed Request</param>
    /// <param name="AdvDocProcessingLog">This log is already committed and contains execution status and error messages.</param>
    [IntegrationEvent(false, false)]
    local procedure OnAfterAdvDocRequestProcessing(var AdvDocRequest: Record "EOS AdvDoc Request"; var AdvDocProcessingLog: Record "EOS AdvDoc Processing Log")
    begin
    end;

(Q2) In the Selection report, I added a report that has a different table from the document. How do I handle it?

For example, this occurs when a second record, such as the bank statement, is added to the selection report of posted invoices. This report has the customer as the starting table, and then running the second entry by passing it the “Sales Invoice Header” would raise a different table error.

An event has been specially added to handle this situation:

codeunit 18122026 "EOS Adv Mail Sandbox"
/// <summary>This event allows you to print a different record than expected. For example, pass a "customer" record filtered appropriately
/// in place of the document that you originally wanted to print</summary>
/// <param name="AdvDocDocuments">Reference to the original record to be printed</param>
/// <param name="TempReportSelection">Current Report Selection</param>
/// <param name="DocumentToPrint">Open this recordref and apply filters. This record will be passed to the report.</param>
/// <param name="Handled">Return true to override default recordref and use instead returned DocumentToPrint recordref.</param>
[IntegrationEvent(false, false)]
local procedure OnOpenRecordRefToPrint(AdvDocDocuments: Record "EOS AdvDoc Documents"; var TempReportSelection: Record "Report Selections"; var DocumentToPrint: RecordRef; var Handled: Boolean)

This event is raised whenever a “RecordRef” must be instantiated from a selection report. By subscribing to this event you can then know which Report Selection we are printing and therefore open the RecordRef appropriately.

In the example described above, we would get to the AdvDocDocuments table the RecordID that we need to print, the “Sales Invoice Header”, but seeing that a report has been added to the selection report that has a “Customer” as the starting table, then there is we charge us to launch the report on the right record.

This deliberately under-optimized example does exactly what we need:

[EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS Adv Mail Sandbox", 'OnOpenRecordRefToPrint', '', False, True)]
local procedure OnOpenRecordRefToPrint(AdvDocDocuments: Record "EOS AdvDoc Documents"; var TempReportSelection: Record "Report Selections"; var DocumentToPrint: RecordRef; var Handled: Boolean)
var
    Customer: Record Customer;
    SalesInvoiceHeader: Record "Sales Invoice Header";
    RecRef: RecordRef;
begin
    if AdvDocDocuments."EOS Table No." <> database::"Sales Invoice Header" then
        exit;

    if TempReportSelection."Report ID" <> {Mio Report Estratto Conto} then
        exit;

    //Apro un secondo RecordRef...
    RecRef.Open(AdvDocDocuments."EOS Table No.");

    //...caricando il record che devo stampare
    RecRef.Get(AdvDocDocuments."EOS Record ID");

    //Carico il cliente su cui lanciare l'estratto conto
    Customer.Get(RecRef.Field(SalesInvoiceHeader.FieldNo("Sell-to Customer No.")));

    //Apro il RecordRef, passato per riferimento, sulla tabella "Customer"
    DocumentToPrint.Open(Database::Customer);

    //Carico il record del cliente
    DocumentToPrint.Get(Customer.RecordId());

    //Filtro la tabella sul record corrente, così l'estratto conto non elabora tutti i clienti della tabella ma solo il nostro
    DocumentToPrint.SetRecFilter();

    //Imposto Handled a True, così il chiamante usa il nostro record
    Handled := true;
end;

EOS Labs -