Can I use a template in a SMTP image attachments?

Hi I have a dynamic image filename given by a template sensor, but when I put the template sensor in my YAML it gives an error.

Has anyone else managed to do this and if so, how? Thanks