- Stefan Hulls
Automator mail attachments
Business case:
If you integrate a small service provider via an email interface it is important to send attachments too. Thinking the other way around, attachments from the Service provider have to appear in the ITRP note of the request.

Email out attachments:
Adding a couple of lines of code to your existing mail out package makes it possible to send inline images and non-inline attachments.
// attach all inline images
$mailAttachments = [];
//Exec Engine v1: foreach($note in $request.notes) {
for($note of $request.notes) {
for($noteAtt of $note.attachments) {
if ($noteAtt.inline) {
$mailAttachments.push({
filename: $noteAtt.name,
path: $noteAtt.uri,
cid: "link-inline" // looks better on apple mail
//cid: uuid() // instantly loaded on outlook
});
}
}
}
//and non-inline attachment of last note
$lastNote = $request.notes.last();
for($noteAtt of $lastNote.attachments) {
if ($noteAtt.inline == false) {
$mailAttachments.push({
filename: $noteAtt.name,
path: $noteAtt.uri
});
}
}
$mailData.attachments = $mailAttachments;
Email in – add attachments to the note:
Adding attachments from an incoming email to the note is even simpler. In that case you just need to add one line to the update statement.
update("requests",$request.id,{
note:$mail.body,
attachments:$mail.attachments
});
Note:
These couple of lines of code help significantly to reduce coordination problems because of missing information.