Powershell - Send Email
Um ein Email mit Powershell zu versenden benötigt man nur einige wenige Zeilen Code:
$SmtpServer = "localhost"
$From = "someone@here.com"
$To = "someone@internet.com"
$Subject = "Greetings from MSH"
$Body = "Hello, SomeOne `n Greetings from MSH"
$Attachment = new-object Net.Mail.Attachment("C:\test.txt")
$message = New-Object system.net.mail.mailmessage ($from,$to,$subject,$body)
$message.attachments.add($attachment)
$SmtpClient = new-object system.net.mail.smtpClient
$SmtpClient.host = $SmtpServer
$SmtpClient.Send($message)
That’s it ;o)