//===========================================================================
// Function: SendMessage(Subject, MessageText, Recipients, MapiProfile)
// Author:   David K. Yowell
// Date:     4/23/99
// Example:  SendMessage("Admin Notice", "Backup failed.", "yowelld@hbh.com");
// Notes:    1) The parameter MapiProfile is optional. If not supplied, the
//              default profile is read from the registry.
//           2) Multiple recipients may be specified by separating addresses
//              with semicolons, e.g., "wallace@aardman.com;gromit@aardman.com".
//           3) Any type of address may be used: Exchange, SMTP, etc...
//===========================================================================
function SendMessage(Subject, MessageText, Recipients, MapiProfile) {
  if (MapiProfile == null) {
    objShell = new ActiveXObject("WScript.Shell"); // to work in WSH and HTA's
    MapiProfile = objShell.RegRead('HKCU\\Software\\Microsoft\\' +
      'Windows Messaging Subsystem\\Profiles\\DefaultProfile');
  }
  objMapi = new ActiveXObject("MAPI.Session");
  objMapi.Logon(MapiProfile);
  objMsg = objMapi.Outbox.Messages.Add();
  objMsg.Subject = Subject;
  objMsg.Text = MessageText;
  arrayRecipients = Recipients.split(";");
  for (i = 0; i < arrayRecipients.length; i++) {
    objRecip = objMsg.Recipients.Add();
    objRecip.Name = arrayRecipients[i];
    objRecip.Resolve();
  }
  objMsg.Send();
}

