How to send document via email from libreoffice

Another way. Not fully automated. Use Thunderbird Add-on ‘Mail Merge’ by Alexander Bergmann.
The {{attachment}} variable also allows you to attach personalized files to emails.

For completeness, a code snippet sending one mail with one PDF attachment to one receipient. After your macros generated the office documents and some configuration data, a parameterized version of such script could be called as a macro or via Basic’s shell command.