Below you can find a simple example on how to send an email from Gmail after process is finished either with „success“ or „error“.
Create file ‚my_file.bat‘ like this (in the first line enter the path to your files):
cd C:\Users\user\Desktop\
if /i "%1" NEQ "0" (
if /i "%1" NEQ "1" (
PowerShell.exe -ExecutionPolicy Bypass -file ".\email.ps1" -argument "ERROR" %1
)) else (
PowerShell.exe -ExecutionPolicy Bypass -file ".\email.ps1" -argument "SUCCESS" %1
)
Create file ‚email.ps1‘ like this (change your credentials):
param($argument="none")
$EmailFrom = "emailFrom@gmail.com"
$EmailTo = "emailTo@gmail.com"
$Subject = "RealityCapture process"
$Body = ("Computation finished with result:",$argument)
$SMTPServer = "smtp.gmail.com"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("username", "password");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
In the Application settings, section Progress end notification - Command line process call the ‘my_file.bat’ like this (change to your path):
C:\Users\user\Desktop\my_file.bat $(processResult)
NOTE: You might need to change your Gmail settings allowing less secure apps to access your account.
Alternatively, you can add more parameters to the message such as process ID or process duration.
Comments
0 comments