Codestone Ltd logo

Create a simple message and send it with the SMTPClient Object

// Example: CSMail JScript Example 1
// Summary: Create a simple message and send it with the SMTPClient Object
// Usage:   cscript exjs01.js
//          or
//          wscript exjs01.js


MyMsg=new ActiveXObject("CSMail.Message");            // Create the message object

MyMsg.Subject="Medical Officer's Report";             // Set the message subject
MyMsg.To(1)="kirk@enterprise.com";                    // Set the recipient...
MyMsg.From(1)="bones@enterprise.com";                 // ... and the originator
MyMsg.Sections(1).Body="Its life Jim, but not as we know it."
                                                      
// Set the message body text

SMTP=new ActiveXObject("CSMail.SMTPClient");          // Create an SMTP Client Object
SMTP.Connect("127.0.0.1");                            // Connect to the server - in this case the local machine
SMTP.SendMessage(MyMsg);                              // Send the message
SMTP.Close();                                         // Close the server