blog.icewolf.ch

Let's talk about IT!
posts - 1314, comments - 295, trackbacks - 0

My Links

Archives

Post Categories

icewolf

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)

Print | posted on Saturday, January 19, 2008 2:26 PM | Filed Under [ Powershell ]

Powered by:
Powered By Subtext Powered By ASP.NET