Skip to main content
Older versions of Internet Explorer will not support certain site features. Chrome, Safari, Firefox, and Edge will provide the best experience.
Spok

Sending the E-mail notification by PowerShell Script

 

There is a way to send out the e-mail notification by PowerShell script if the client wants to get any email notification with attached for any file generated by Spok applications or any report which may be generated from the database (SF Case#00634195). Below script is used from a machine with SMTP/IIS enabled and there is the SMTP server is defined, which is accepts anonymous SMTP/relay for IP address of the sending host.

In the script, the sender, test@spok.com, sends the email with the subject, “Email Test with Attached”, body written as “Please check the attached”, and attachment, C:\test\Cardnumber.csv, to the recipients,  John.Doe@spok.com and Tom.test@spok.com,  using the SMTP server as smtp.spok.com and the default port number for SMTP as 25.

 

$From = "test@spok.com"

$To = "John.Doe@spok.com"

$Cc = " Tom.test@spok.com"

$Attachment = " C:\test\Cardnumber.csv"

$Subject = " Email Test with Attached "

$Body = " Please check the attached "

$SMTPServer = " smtp.spok.com "

$SMTPPort = "25"

Send-MailMessage -From $From -to $To -Cc $Cc -Subject $Subject -Body $Body -SmtpServer $SMTPServer -port $SMTPPort -Attachments $Attachment