The one known issue is that ItemAdd won't fire if more than 16 items are added to the folder at one time.
How about ItemChange? Is that firing for the Inbox folder? If you manually run the Application_Startup procedure, do both Items event handlers start working?
FWIW, that's not VBScript, but VBA code. There's a big difference.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
<(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> The following is a very simple VBScript to popup a massage box when new
> mails arrived to the inbox.
> ========================================================
> Dim Inbox As Folder
> Dim InboxMails As Items
>
> Private Sub Application_Startup()
> Set Inbox = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
> Set InboxMails = Inbox.Items
> End Sub
>
> Private Sub InboxMails_ItemAdd(ByVal Item As Object)
> MsgBox "Item ADD"
> End Sub
> Private Sub InboxMails_ItemChange(Item As Object)
> MsgBox "item change"
> End Sub
> ========================================================
> I also added this to check whether InboxMails is properly set;
>
> Private Sub Application_FolderContextMenuDisplay(ByVal CommandBar As
> Office.CommandBar, ByVal Folder As MAPIFolder)
> 'To test InboxMails is properly set.
> Set Inbox = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
> Set InboxMails = Inbox.Items
> MsgBox "There " & InboxMails.Count & " mails in the inbox"
> End Sub
>
> When I right cliked a folder the massage box worked as I expected. Thus
> I'm sure
> that the InboxMails is set to an Items object. But InboxMails_ItemAdd
> nor
> InboxMails_ItemChange worked. I tried many times but in vein. What's
> wrong
> with my code? Please help me. Thank you.
>