Winscripter
  WSH
  Forums
  Downloads
  Books
  Links
  Amazon




Login
Register

© winscripter.com
1998-2004







Script: MAPI - Find Size of Inbox

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

Script: Opens Outlook Profile using MAPI and enumerates through the messages and display the total size of the messages.

 

/**
 *    Script:   ol98InboxSize.js
 *    Purpose:  Opens the Inbox for the Outlook profile defined
 *              adds the sizes all messages and shows total to user. 
 *    Author:   Daren Thiel
 *    Date:     24 November 1998
 *
 *    Note:     This script will only find the total for messages
 *              in the inbox, no Inbox child folders will be looked at.
 * Web:     
http://www.winscripter.com         
 **/
/* 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;
var mSize  = 0;            // Counter to store sum of message sizes
var mCount = objMsg.Count; // Get the number of messages
/* Loop through all the messages and add their size to the total */
for ( i = 1; i < mCount; i++ )
{
 msg = objMsg.Item(i);
  mSize += msg.Size;
}
/* The total stored in mSize is in Bytes */
/* I will conver to KB for easy reading  */

mSize = Math.round( mSize / 1024 );
/* Display what we found to the user */
var results = "Total number of messages = " + mCount + "\n";
results += "Size of Inbox = " + mSize + " KB";
WScript.Echo( results );



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