Hi Everyone,
I try to send an email with an attached document, this code works very well, but I need to write a specific text for each email, for now the body arrives empty, does anyone know how to modify it?
thank you so much
//My code
Hi Everyone,
I try to send an email with an attached document, this code works very well, but I need to write a specific text for each email, for now the body arrives empty, does anyone know how to modify it?
thank you so much
//My code
Hello Tech, I solved it in another way using a temporary table before sending the mail, and adding a procedure inside the event subscription, I have solved the problem, thank you very much for your help
greetings
for that, you need to customize it more , you can subscribe OnBeforeSendEmail event as shown in the below image and exit the standard code it has the PostedDoc No as a parameter you can use it and re-write the Standard code on your custom code for further process then you can directly modify the body as well without subscribing the previous event that I told you.
this is the Function EmailFileInternal in Codeunit "Document-Mailing" You can explore more for a much better solution I just explained one of the possibilities.
Hi tech, thanks, this works, but I need to add details of the Sales Invoice Header record to the body of the email. I don't see in that event that I receive the record as a parameter. Do you know how I can map it from the subscription?
thank you so much
You need to use the Event to modify the Email Body as bellow :
[EventSubscriber(ObjectType::Table, database::"Email Item", 'OnBeforeGetBodyText', '', false, false)] local procedure OnBeforeGetBodyText(var EmailItem: Record "Email Item"; var Value: Text; var IsHandled: Boolean) begin IsHandled := true; //Write your custom email Body here value := 'Please Find the attched Invoice'; // this is just an example end;
But I tried your code and that does not send the email with the empty body the default body is quite good you can see the screenshot :
after using the event I modified the body and received the mail as bellow :
I hope this helps you if YES please verify this answer
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,269 Super User 2024 Season 2
Martin Dráb 230,198 Most Valuable Professional
nmaenpaa 101,156