Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
in CompleteFTP by (120 points)
I would like to send a single email containing a list of files uploaded during a session.  With 'upload' I get one per file, with 'log out' I get nothing.

1 Answer

0 votes
by (46.8k points)

You can do this using two process triggers of type JSS.  The first one triggers for each uploaded files and stores the path of the uploaded file in memory.  The second one triggers on log-out and sends the email containing the list of files.

Process trigger 1:

  • Name: Remember uploads
  • Events: Upload file
  • Type: JSS script
  • Script below:
if (!system.user.tags.get("uploads"))
    system.user.tags.set("uploads", "[]");
var uploads = JSON.parse(system.user.tags.get("uploads"));
system.user.tags.set("uploads", JSON.stringify(uploads));

Process trigger 2:

  • Name: Email uploads on log out
  • Events: Log out
  • Type: JSS script
  • Script below:
var uploads = system.user.tags.get("uploads");
if (uploads) {
    uploads = JSON.parse(uploads);
    var message = "The following files were uploaded:\r\n";
    for (var i in uploads)
        message += "- " + uploads[i] + "\r\n";

    mail.smtp.server = "smtp.gmail.com";
    mail.smtp.port = 587;
    mail.smtp.userName = "my.account@gmail.com";
    mail.smtp.password = "my.password";
    mail.smtp.enableSSL = true;

    mail.send("sender@test.com", "recipient@test.com", "Files uploaded", message);

Make sure you change the SMTP settings to match your mail server and account.