To, CC, BCC, ReplyTo, From, Sender and Subject Properties
' Example: CSMail VBScript Example 8
' Summary: To, CC, BCC, ReplyTo, From, Sender and Subject Properties
' Usage: cscript exvbs08.vbs
' or
' wscript exvbs08.vbs
' 1) Set the fields the easy way - through the properties
WScript.echo("First method")
set MyMsg=CreateObject("CSMail.Message") ' Create the message object
MyMsg.To(1)="kirk@enterprise.fed" ' Add first primary recipient
MyMsg.To(2)="spock@enterprise.fed" ' Add second primary recipient
MyMsg.CC(1)="checkov@enterprise.fed" ' Add first copy recipient
MyMsg.CC(2)="sulu@enterprise.fed" ' Add second copy recipient
MyMsg.BCC(1)="bones@enterprise.fed" ' Add first blind copy recipient
MyMsg.BCC(2)="scotty@enterprise.fed" ' Add second blind copy recipient
MyMsg.From(1)="uhura@enterpise.fed" ' Could have multiple Froms if we wanted
MyMsg.Sender(1)="uhura@enterpise.fed" ' Can only have one Sender
MyMsg.ReplyTo(1)="uhura@enterpise.fed"
MyMsg.Subject="Message from Starfleet Headquarters"
' Note - setting these properties automatically updates appropriate Fields in the Messge Header collection
' Let's dump the Header to see what's happened-
' Show all the MIME message fields
WScript.echo("Dumping all MIME Fields:")
for each field in MyMsg.Header
WScript.echo("--"&field&"="&MyMsg.Header(field))
next
' 2) Set the properties the harder (?) way - through the Header OLE collection ...
WScript.echo("Second method")
set MyMsg=CreateObject("CSMail.Message") ' Create a new message object
myMsg.Header("To")="kirk@enterprise.fed,spock@enterprise.fed"
myMsg.Header("CC")="checkov@enterprise.fed,sulu@enterprise.fed"
myMsg.Header("BCC")="bones@enterprise.fed,scotty@enterprise.fed"
myMsg.Header("From")="uhura@enterpise.fed"
myMsg.Header("Sender")="uhura@enterpise.fed"
myMsg.Header("Reply-To")="uhura@enterpise.fed"
myMsg.Header("Subject")="Message from Starfleet Headquarters"
' Note - setting these properties automatically updates the appropriate properties
' Let's dump the properties to check...
WScript.echo("'To' recipients:")
for each address in MyMsg.To
WScript.echo "--"+address
next
WScript.echo("'CC' recipients:")
for each address in MyMsg.CC
WScript.echo "--"+address
next
WScript.echo("'BCC' recipients:")
for each address in MyMsg.BCC
WScript.echo "--"+address
next
' etc.....
|