Email Attachment Filename

Hi,

I was trying to change the filename of the email attachment.

I created a Control Script to handle this matter.

Is it possible to create a condition based on Metadata values?

for example if the metadata field = A

then file name =Apple

many thanks

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?

No not really.

How can I achieve that without using the metadata if it’s not going to be convenient?

Need a bit more context here:

  • 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:

var section = merge.template.contexts.PRINT.sections['Section 1'];
var emailAttachName = record.fields.docType == "Invoice" ? 'Invoice#' + record.fields.CustomerNo : 'Statement#' + record.fields.CustomerNo;
section.part = emailAttachName;