Hello Ryan,
Yes, that's possible using a PowerShell script and a built-in PowerShell cmdlet called Send-MailMessage. Here's an ecxample of a PowerShell script that sends an attachment specified by $filePath to a recipient specified by $to. Also, modify the following to match your requirements:
- $from - specifies the message sender
- $smtpServer - specifies the SMTP server to use to send the message,
- $messageSubject - specifies the message subject,
- $messageBody - specifies the text in the message body
$filePath = "\\SERVER\Share\MyFile.pdf" # TODO: modify me
$to = "recipient@example.com" # TODO: modify me
# Email message setings
$from = "noreply@domain.com" # TODO: modify me
$smtpServer = "mail.example.com" # TODO: modify me
$messageSubject = "My Subject" # TODO: modify me
$messageBody = "Message Text" # TODO: modify me
if(!(Test-Path -Path $filePath))
{
$Context.LogMessage("File not found.", "Error")
return
}
# Send message
Send-MailMessage -To $to -from $from -SmtpServer $smtpServer -Subject $messageSubject -Body $messageBody -Attachments $filePath
To run the script in a Custom Command, use the Run a program or PowerShell script action.