[Bug] OnAfterEmailSentSuccesfully doesn't provide latest version of the "Email Item"
When you sent a document via email then an email dialog opens. In this dialog you have the possibility to change information like the To address for example. In the OnAfterEmailSentSuccesfully event you don't receive this change, the provided "Email Item" still has the old value.
Do you have any status update on this, please?
Please be more detailed. We may not understand your issue, if you need to update TempEmailItem before send, you probably need to use this event
IsHandled := false;
OnBeforeSendEmail(TempEmailItem, IsFromPostedDoc, PostedDocNo, HideDialog, ReportUsage, EmailSentSuccesfully, IsHandled);
if IsHandled then
exit(EmailSentSuccesfully);
I have added the following subscriber to OnAfterEmailSentSuccesfully
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Document-Mailing", 'OnAfterEmailSentSuccesfully', '', false, false)]
local procedure OnAfterEmailSentSuccesfully(var TempEmailItem: Record "Email Item" temporary; PostedDocNo: Code[20]; ReportUsage: Integer)
begin
Message(TempEmailItem."Send to");
end;
I try to send a posted invoice via mail. I do this by navigating to the posted sales invoices and then send a mail via "Print/Send" => Send....
I confirm the next dialog with these settings.

After this, the email dialog opens.

In this window I change the To email address to another valid address and send the mail. The message shows the old email address instead of the new entered one.
I've just tested this on BC 16.1 and this is still not working properly. The "old" version of the Email Item is retrieved. When will this be fixed?
I think this is currently By Design, as TempEmailItem is only temporary table to pass parameters to Mail sending process and there is no easy way to return changed data back. So this is not a problem of existing event, but more deeper design question. I will forward this ask to another team focused on EMailing story.
We are currently redoing our email story, to be released with the next major. This issue will be considered in the new implementation.