Instead of using metadata (as these will have mostly come from the datamapper), you could also conditionally set the filename in the datamapper or even in the Control script.
Is there any specific constraint which forces you to use metadata?
Is the email attachment an external file or it it the PDF generated by the Print context?
Can you provide details of how you would like to rename the attachment? Do you have a field in the data mapper for this purpose?
Will the field value be conditional based upon th evalue of another field in the data? If so, can you provide details?
For instance let’s assume you have two fields. One is docType which indicates whether the document is an ‘Invoice’ or a ‘Statement’; and the other field being the CustomerNo.
So your control script setting the email attahment name could be: