CDO.Message w Powershell#

Kiedyś napisałem posta o CDO.Message w VBScripcie , teraz więc pora na Powershella.

$objMessage = new-object -com CDO.Message
$objMessage.From = "`"Krzysztof Pietrzak`" <pkrzysz@nospam.pjwstk.edu.pl>"
$objMessage.To = "pkrzysz@nospam.pjwstk.edu.pl"
$objMessage.Subject = " Message Subject"
$objMessage.TextBody = "Body of message"
# Send using SMTP
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
#SMTP Server
$objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.server.org"
#SMTP Server Port
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
#Authenticaztion 1-Baasic, 2-NTLM
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 2
#Use ssl
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 0
#Timeout
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

$objMessage.Configuration.Fields.Update()
$objMessage.Send()

I oczywiście przykład z uzyciem normalnej autoryzacji i SSL/TLS:

$objMessage = new-object -com CDO.Message
$objMessage.From = "`"Krzysztof Pietrzak`" <pkrzysz@nospam.pjwstk.edu.pl>"
$objMessage.To = "pkrzysz@nospam.pjwstk.edu.pl"
$objMessage.Subject = " Message Subject"
$objMessage.TextBody = "Body of message"
# Send using SMTP
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
#SMTP Server
$objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "dfs2"
#SMTP Server Port
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
#Authenticaztion 1-Baasic, 2-NTLM
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
#UserID
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "yourUser"
#Password
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"
#Use ssl
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
#Timeout
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

$objMessage.Configuration.Fields.Update()
$objMessage.Send()


 

Monday, June 05, 2006 10:58:04 AM (Central European Standard Time, UTC+01:00) #    Comments [0]  |  Trackback

 

All content © 2009, Krzysztof Pietrzak
On this page
This site
Calendar
<January 2009>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567
Archives
Sitemap
Blogroll OPML
  Tokyo by night
blog WiTa
  W-Files
blog n€x¤Ra
 .:fotoblog:.
blog Kfaza
 \\archon\blog$
blog archona
 Czasowstrzymywacz
Blog Fookyego
 Jog Pstryka
Jog Pstryka
 Mac OS X vs. Active Directory
techniczny blog kfaza

Maps
Locations of visitors to this page