Maybe you could try something different.
You could define your HTML using the DocumentTemplate from Mendix Studio PRO. You generate an HTML Document via the template where you customize it as you can. Then you could use the StringFromFile method from the community commons.
https://docs.mendix.com/appstore/modules/community-commons-function-library/#:~:text=StringFromFile%20%E2%80%93%20This%20reads%20the%20contents%20from%20the%20provided%20file%20document%20and%20returns%20it%20as%20string.%20Multiple%20encodings%20are%20supported%20since%20version%207.4.1%20of%20the%20module.
You get the string from the document and attach that string to your email message via the email template token.