View Categories

Email Example

1 min read

For this example we’ll use a powershell script that sends an email to the admin when a new file has been uploaded to ProVide.

# Setup script parameters
param ([Parameter(Mandatory=$true)][string]$local, [Parameter(Mandatory=$true)][string]$ftp)
# Email parameters
$SMTPServer = “mailserver.domain.com”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587) $SMTPClient.EnableSsl = $true
# The email address that will appear to be the sender of the email. $EmailFrom = “from@domain.com”
# The email address that will receive the email.
$EmailTo = “to@domain.com”
# This will be the subject of the email.
$Subject = “New file”
# The email text that will be sent will be what is contained within the ‘@”‘ in the start and the ‘”@’ in the end.
$Body = @”
A new file has arrived through $ftp, ending up in $local.
Best regards,
ProVide
“@
# If credentials are required for sending through this SMTP server $SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“domain\user”, “password”);
# If we should skip certification validation check for this SMTP server [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { return $true }
# Now we are ready to send the message $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

We want this script to trigger when a user is done uploading a file so go to the “Messages and events” in the provide administrator interface and select “OnUploadEnd” from the drop-down menu. We want to add the follow line to the message box:

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

This line is telling ProVide that when the upload has been finished it will execute the powershell script located at the path and it will send with it the ‘local_filename’ and ‘ftp_filename’.

If you wish to read more about this subject you can go to our CMD examples.

Thank you for downloading ProVide Server

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

Your Cart

Header test Qty Price
display quantity price
Product Name Qty Price

Thank you for showing interest in trying ProVide Server

Follow the 3 easy steps below to install ProVide Server

Subtotal: Total
Total (inc. VAT): Total
Tax: Total
You save: Total

Medi trial

Thank you for showing interest in trying ProVide Server

Follow the 3 easy steps below to install ProVide Server

Maxi trial

Thank you for showing interest in trying ProVide Server

Follow the 3 easy steps below to install ProVide Server

Free Trial

Get
ProVide Software