Hey!
There's a few errors with your code so may I suggest you use this tutorial instead which has the correct code (you are incorrectly creating the PDF).
How to send an email with attachments in SAP Cloud Application Studio this is a similar but newer version of the tutorial you are following.