Applies to: Syncplify.me Server!
Version(s): 4.x - 5.x
Warning:    this articles refers to an older version of our software


One of the ready-made script examples that are installed along with Syncplify.me Server! shows how to notify someone via email each time a file is uploaded. But what if you wanted to send only one email, at the end of the file transfer session, with the list of all files that were uploaded in such a session?


You can easily do that with 2 simple scripts bound to 2 different event handlers.


First of all, you will need a script bound to the “AfterFileUpload” event handler, to keep the list up to date:

begin
  Session.CustomDataEx.Add(VirtualObjectName); // requires Syncplify.me Server! v4+
end.


Then you will need a script bound to the  “OnSFTPClose” and “OnFTPSClose” event handlers, to send out the email when the user disconnects from either protocol:


var
  MailText: string;  
begin
  MailText := 'SFTP connection came from '+Session.ClientIP+#13#10;
  MailText := MailText+'User was authenticated as '+Session.ReqUsername+#13#10;
  MailText := MailText+#13#10;
  MailText := MailText+'List of all uploaded files during the session:'+#13#10;
  MailText := MailText+Session.CustomDataEx.Text+#13#10;
  MailText := MailText+#13#10;
  MailText := MailText+'Thank you,'+#13#10;
  MailText := MailText+'best regards.'+#13#10;
  MailText := MailText+#13#10;
  MailText := MailText+'Your Syncplify.me Server!'+#13#10;
  SendMail('your_email@here.com', 'Client session ended', MailText, '');
end.


That's it. Easy and straightforward.