Last active
August 29, 2015 13:57
-
-
Save ploegert/9898974 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #============================================================================== | |
| # SEND EMAILS Helper | |
| #============================================================================== | |
| function SendEmailAlert() | |
| { | |
| PROCESS | |
| { | |
| write-host "`nSending Email to Notification List with subject of: $EmailSubject`n" -foregroundcolor yellow | |
| $smtpServer = "SERVER" | |
| $emailFrom = "justin.j.ploegert@jci.com" | |
| $emailTo = "justin.j.ploegert@jci.com" | |
| $emailsubject = "BAS-API Reboot" | |
| $emailbody = "The BAS-API Service at: $ServiceName, Instance: $InstanceName was just rebooted." | |
| sendEmail $emailFrom $emailTo $emailsubject $emailbody $smtpServer | |
| } | |
| } | |
| #============================================================================== | |
| # SEND EMAILS!!! | |
| #============================================================================== | |
| # Usage | |
| # do_sendemail -emailmesage "Your FCopy is done" -emailsubject "Your FCopy is done" -emailto "4143504764@pm.sprint.com" | |
| # do_sendemail -emailmesage "Your FCopy is done" -emailsubject "Your FCopy is done" -emailto "justin.j.ploegert@jci.com" | |
| #============================================================================== | |
| Function sendemail([string]$emailFrom, [string]$emailTo, [string]$subject,[string]$body,[string]$smtpServer ,[string]$filePath) | |
| { | |
| #initate message | |
| $email = New-Object System.Net.Mail.MailMessage | |
| $email.From = $emailFrom | |
| $email.To.Add($emailTo) | |
| $email.Subject = $subject | |
| $email.Body = $body | |
| # initiate email attachment | |
| #$emailAttach = New-Object System.Net.Mail.Attachment $filePath | |
| #$email.Attachments.Add($emailAttach) | |
| #initiate sending email | |
| $smtp = new-object Net.Mail.SmtpClient($smtpServer) | |
| $smtp.Send($email) | |
| write-host "Email Sent to $emailTo" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment