Winscripter
  WSH
  Forums
  Downloads
  Books
  Links
  Amazon




Login
Register

© winscripter.com
1998-2004







Script: Send Email using MAPI

Posted by on Sunday, January 18, 2004 (PST)

Script: Send email using MAPI. MAPI Profile must be configured on the machine in order to properly execute.

 


/**
 *    Name:       simpleEmail.js
 *    Purpose:    Demonstrate using MAPI to send Email using WSH
 *    Author:     Daren Thiel
 *    Date:       17 November 1998
 * 
 *    Note:       Rename this file simpleEmail.js
 *    Web:       
http://www.winscripter.com
 **/
 
 omapi = new ActiveXObject("MAPI.Session");
 omapi.Logon("daren");
 
 objmsg = omapi.Outbox.Messages.Add();
 objmsg.Subject = "Sample Message";
 objmsg.Text = "This is text message";
 
 objRecip = objmsg.Recipients.Add();
 objRecip.Name = "psdrt@yahoo.com";
 objRecip.Type = 1;
 objRecip.Resolve();
 
 var err = objmsg.Send();
 WScript.Echo( "Message Sent" );
 

Comments:

Doesn't work
By peter on Thursday, July 15, 2004 (PST)
When I try to use this code, I get an error that says "Automation Server can't create object." I get this error on the line omapi = new ActiveXObject("MAPI.Session"); Any idea about the cause? I have outlook 2000 installed, btw.

For older clients
By Daren on Tuesday, August 31, 2004 (PST)

Peter,

 

Sorry I missed you posting this comment.

 

This is for systems with the older MAPI client loaded.  Such as Oulook 98.

 

I recommend using the CDO method for newer systems or using wsInetTools.SMTP to send email.

 

Daren



WSH and ADSI Administrative Scripting

New Articles
  • List installed COM objects and associated ProgIDs
    Script: Lists all COM Objects and their associated ProgIDs (If available). Win32_ClassicCOMClassSetting

  • Script: File Rotator
    Script: Rotate files where the most current file has the lowest number in the archive. When files exceed the retention period, they are deleted. Typically used for log files, backups, etc..

  • Script: Create IIS Website and DNS record
    Script: Dan Casier sent me this script that will create a website and appropriate DNS record. The script is intended for Windows 2000 Server with local DNS and necessary DNS mof installed.


  • Winscripter   |  WSH   |  Forums   |  Downloads   |  Books   |  Links   |  Amazon