General Tasks
Often you might be required to send out emails containing particular reports and/or output from commands run.
To do so, you use features from the .NET Framework via PowerShell to send out emails, as shown in here:
Function Send-Mail {param([string]$To,[string]$From,[string]$Subject, ` [string]$Body,[string]$File,[string]$SmtpServer) If($SmtpServer -eq ""){ $SmtpServer = "FQDN of your SMTP server here" } $Smtp = New-Object System.Net.Mail.SMTPclient($SmtpServer) $Message = New-Object System.Net.Mail.MailMessage($From,$To,$Subject,$Body) If ($File -ne "") { $Attach = New-Object System.Net.Mail.Attachment $File $Message.Attachments.Add($Attach) } $smtp.Send($message)}
You can enter the ...
Get Microsoft® SQL Server 2012 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.