KiX-script using OLE-Functions to send Outlook E-mails.This script can be used to send mail from NT/2000. (In Win9x OleCallFunc dosn't work)
code:
;Create OLE-handle to Outlook
$MailApp = OleCreateObject("Outlook.Application")
;Create New mail item
$NewMail = Val("&" + OleCallFunc($MailApp, "CreateItem", "s", "0"))
;Get handle for recipients
$Recipients = Val("&" + OleGetProperty($NewMail, "Recipients"))
;Add Recipient(s), make a loop if you want to add more than one recipient
$Mailto = "Recipient@Domain.com"
$Err = OleCallProc($Recipients, "Add", "s", "$MailTo")
;Insert the text(body) in the mail
$Msg = "This is a test"
$Err = OlePutProperty($NewMail, "Body", "s", "Msg")
;Send the mail
$Err = OleCallProc($NewMail, "Send")
;Release all handles obtained by OleCreateobject, OleCallFunc and OleGetProperty
$Err = OleReleaseObject($Recipients)
$Err = OleReleaseObject($NewMail)
$Err = OleReleaseObject($MailApp)
Erik[This message has been edited by kholm (edited 28 January 2001).]