Loading
View Categories

How do I get ProVide to email me when a file is uploaded?

ProVide can send an automatic email when a file finishes uploading, using a PowerShell script triggered by the Events and Messages module. This example emails the admin every time a new file arrives, including where it came from and where it landed.

Here is the PowerShell script. Save it as a .ps1 file on the server.

# Script parameters passed in by ProVide
param (
    [Parameter(Mandatory=$true)][string]$local,
    [Parameter(Mandatory=$true)][string]$ftp
)

# Email / SMTP settings
$SMTPServer = "mailserver.domain.com"
$SMTPClient = New-Object Net.Mail.SmtpClient($SMTPServer, 587)
$SMTPClient.EnableSsl = $true

# Address the email appears to come from
$EmailFrom = "from@domain.com"
# Address that receives the email
$EmailTo = "to@domain.com"
# Subject line
$Subject = "New file"

# Body: everything between @" and "@
$Body = @"
A new file has arrived through $ftp, ending up in $local.
Best regards,
ProVide
"@

# Supply credentials if your SMTP server requires them
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("domain\user", "password")

# Optional: skip SMTP certificate validation (not recommended, see note below)
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { return $true }

# Send the message
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

Trigger the script from ProVide #

You want this to run when a user finishes uploading a file. In the ProVide administration interface, open Events and Messages, then select “OnUploadEnd” from the drop-down menu. Add this line to the message box:

%EXECUTE(Powershell.exe -File "c:\PATH\TO\SCRIPT\SCRIPT.ps1" -local "%LOCAL_FILENAME%" -ftp "%FTP_FILENAME%")%

This tells ProVide to run the PowerShell script at that path when an upload completes, passing the local file path (%LOCAL_FILENAME%) and the path the user uploaded to (%FTP_FILENAME%) into the script’s -local and -ftp parameters.

For a batch-script version of the same idea, see CMD script examples.

YOUR CART

CUSTOMERS ALSO ADD

HAVE A COUPON?
ORDER SUMMARY
We'll send a tailored quote to your inbox.

The invoice will be e-mailed once your order is confirmed.

ProVide Server

Your cart is empty

maxi_provideserver

Choose your version of ProVide Server to download

For the ultimate experience of ProVide’s features and functions,
we recommend choosing the MAXI License.

Follow the 3 easy steps below to install ProVide Server
  1. Download the version you need using the buttons below.
  2. Get a free MAXI trial license by clicking the “Get Maxi Trial License” button and enter your email. The license key will be sent to your email.
  3. Activate the license key by following this simple step-by-step-guide.

Free Trial

Get
ProVide Software