Thursday, September 22, 2005
Sending email using MSH
This example is modified from one of my old VBScripts. It uses CDO to send message.
This example is modified from one of my old VBScripts. It uses CDO to send message.
function email
($from, $to, $subject, $textbody)
{
$msg = new-object -com CDO.Message
$msg.From = $from
$msg.To = $to
$msg.Subject = $subject
$msg.Textbody = $textbody
$msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
$msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.nospam.com"
$msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
$msg.Configuration.Fields.Update()
$msg.Send()
}
email "someone@nospam.com" "someone@nospam.com" "test using msh" "hello, world!"