I need to send out emails in a workflow and need to attach a file.
The code for sending my emails is:
emailService.send(
template = "myTemplate"
, recipientId = someID
, args = { someArgs = someValue }
);
The documentation says I need to attach the file(s) within the params
attribute, but here is where I’m stuck.
I tried a buildLink to the attachment, but without any result.
What’s the way here to attach one ore more files?
Thanks,
Michi
sacha
2
You can do it like this:
var attachmentBinary = fileReadBinary( tmpPdfFile );
emailService.send(
template = "myTemplate"
, recipientId = someId
, args = { someArgs = someValue }
, attachments = [
{ name="someFileName.pdf", type="application/pdf", binary=attachmentBinary }
]
);
The template handler can also provide a prepareAttachments
function that’s called automatically. This should return the above attachments
struct.
I hope that helps.
Best,
Sacha
1 Like
This is what I finally did:
var assetMeta = assetManagerService.getAsset( assetID ); // get asset meta data
var assetBinary = assetManagerService.getAssetBinary( assetID ); // get asset binary
// send email
emailService.send(
template = ListLast(qParticipant.certificateFolder,"/")
, recipientId = qParticipant.id
, args = { teilnehmer=qParticipant.id }
, attachments = [
{ name=assetMeta.file_name & "." & assetMeta.asset_type, type="application/pdf", binary=assetBinary }
]
);
Works fine.
Thanks for the hint.
1 Like