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)="[email protected]" ' Add first primary recipient
MyMsg.To(2)="[email protected]" ' Add second primary recipient
MyMsg.CC(1)="[email protected]" ' Add first copy recipient
MyMsg.CC(2)="[email protected]" ' Add second copy recipient
MyMsg.BCC(1)="[email protected]" ' Add first blind copy recipient
MyMsg.BCC(2)="[email protected]" ' Add second blind copy recipient
MyMsg.From(1)="[email protected]" ' Could have multiple Froms if we wanted
MyMsg.Sender(1)="[email protected]" ' Can only have one Sender
MyMsg.ReplyTo(1)="[email protected]"
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")="[email protected],[email protected]"
myMsg.Header("CC")="[email protected],[email protected]"
myMsg.Header("BCC")="[email protected],[email protected]"
myMsg.Header("From")="[email protected]"
myMsg.Header("Sender")="[email protected]"
myMsg.Header("Reply-To")="[email protected]"
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.....
|