I have done this using Email Templates module via a microflow. In a Send Email microflow, I use Email Templates module to generate the email body with tokens for recipient name and other information. Then, before sending the email, I append an html table to the end of the html body. Here are a few screenshots with details:
Begin table tag and headers:
Each table row
Total row and table end
Maybe this will give you another approach in addition to a custom Java action.
Hope that helps,
You can create the html table in a microflow. Here is a quick example that I put together:
Once you create the html table, you can store it in an attribute and use that as a token in your email.
Hope this helps!