Scheduled script.
Move already forwarded attachments through email to another folder. The attachments are stored in a folder. If they are forwarded move these files to another folder.
//Create a folder search and get all files and store these in an array
let fileFromCabinet = file.load({id : internalId})
internalArray.push(fileFromCabinet);
//Sent an email with that attachment
let emailObj = email.send({
author: -5,
recipients: -5,
subject: ‘ ‘,
body: ‘ ‘,
attachments: internalArray });
log.debug(‘Email sent’, emailObj);
//Call this function to move that files to another folder
moveFilesToFolder(internalArray,folderTo);
const moveFilesToFolder = (internalArray,folderTo) => {
try {
for (let i = 0; i < internalArray.length; i++) {
let fileToMove = file.load({ id: internalArray[i].id });
fileToMove.folder = folderTo;
let fileId=fileToMove.save();
} }catch(e){log.debug(e.message);}
};