Winscripter
  WSH
  Forums
  Downloads
  Books
  Links
  Amazon




Login
Register

© winscripter.com
1998-2004







Script: MAPI - Read Email From Inbox

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

Script: Opens the Inbox for the Outlook profile defined. Reads and displays the body of the first 10 messages.

 

/**
 *    Script:   readMail.js
 *    Purpose:  Opens the Inbox for the Outlook profile defined
 *              and reads the message contents then displays them
 *              to a user. 
 *    Author:   Daren Thiel
 *    Date:     24 November 1998
 *    Web:     
http://www.winscripter.com
 *    Note:     If the message are large the WScript.Echo box will
 *              be larger than the screen area.  By default the OK
 *              button is selected, so pressing enter will clear the
 *              popup from view.
 **/
/* Set the name of the profile to use */
var profile = "Microsoft Outlook Internet Settings";
/* Create a MAPI Session Object */
omapi = new ActiveXObject( "MAPI.Session" ); 
/* Open the profile of where we want to store the address */
omapi.Logon( profile );
/* Create an object for the Inbox of this profile */
objFolder = omapi.Inbox;
/* Create an object for the Messages */
objMsg = objFolder.Messages;
/**
 * Get the first message.  Depending on how the Inbox
 * is sorted will determine which Message is considered
 * the first message.
 **/
myMsg = objMsg.GetFirst();
/* Retrieve the body of the message */
msg = myMsg.Text;
/* Display the message to the user */
WScript.Echo( msg );
/* Loop through the first 10 messages and display */
for ( i = 0; i < 10; i++ )
{
 myMsg = objMsg.GetNext();
  msg = myMsg.Text;
  WScript.Echo( msg );
}

 



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