To, CC, BCC, ReplyTo, From, Sender and Subject Properties
// Example: CSMail JScript Example 8
// Summary: To, CC, BCC, ReplyTo, From, Sender and Subject Properties
// Usage: cscript exjs08.vbs
// or
// wscript exjs08.vbs
// 1) Set the fields the easy way - through the properties
WScript.echo("First method");
MyMsg=new ActiveXObject("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
// Lets dump the Header to see whats happened-
// Show all the MIME message fields
// Show all the MIME message fields
WScript.echo("Dumping all MIME Fields:")
headers=new Enumerator(MyMsg.Header);
for (;!headers.atEnd();headers.moveNext()) {
WScript.echo(headers.item()+"="+MyMsg.Header(headers.item()));
}
// 2) Set the properties the harder (?) way - through the Header OLE collection ...
WScript.echo("Second method");
myMsg=new ActiveXObject("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
// Lets dump the properties to check...
WScript.echo("'To' recipients:");
address=new Enumerator(MyMsg.To);
for (;!address.atEnd();address.moveNext()) {
WScript.echo("--"+address.item());
}
WScript.echo("'CC' recipients:");
address=new Enumerator(MyMsg.CC);
for (;!address.atEnd();address.moveNext()) {
WScript.echo("--"+address);
}
WScript.echo("'BCC' recipients:")
address=new Enumerator(MyMsg.BCC);
for (;!address.atEnd();address.moveNext()) {
WScript.echo("--"+address);
}
// etc.....
|