View Single Post
  #3  
Old May 29th 08, 04:21 PM posted to microsoft.public.outlook.program_vba
Trefor
external usenet poster
 
Posts: 27
Default Problem using NewMailEx

Sue,

Thankyou for the feedback. I have tried to change the code to match your
suggestion, but being a newbie to Outlook VBA I seem to be struggling.

I want to monitor a specific folder not just the Inbox. Below is my code,
can you let me know what I have done wrong. Also all my code is in
ThisOutlookSession, is this a problem?


Option Explicit
Private WithEvents InputFolder As Items

Private Sub Application_Startup()
Dim olNS As NameSpace
Dim InputFolder As Outlook.MAPIFolder
Dim ProcessedFolder As Outlook.MAPIFolder
Dim olMail As Items

Set olNS = Outlook.Application.GetNamespace("MAPI")

' Get reference to folder in user’s Mailbox for Input
Set InputFolder = olNS.Folders("Mailbox - Partners").Folders("Order
Notification")

' Get reference to folder in user’s Mailbox for Output (or Processed)
Set ProcessedFolder = olNS.Folders("Mailbox - Partners").Folders("Order
Notification Processed")

' Get reference to items in folder
Set olMail = InputFolder.Items

End Sub


Private Sub InputFolder_ItemAdd(ByVal Item As Object)

.....stuff

End Sub




--
Trefor


"Sue Mosher [MVP-Outlook]" wrote:

Correct: NewMailEx fires only for the user's own mail accounts, not for new mail delivered to other mailboxes opened as secondary mailboxes. The event to use for folders from other mailboxes would be MAPIFolder.Items.Add.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Trefor" wrote in message ...
We have several users sharing a mailbox using the "Open these additional
mailboxes" option. Trouble is even if the VBA code is setup using this
configuration the procedure will not fire. If I create a new profile and
start outlook directly to this mailbox the sub routine fires just fine.

Does NewMailEx only work when you open the mailbox directly? Or am I doing
something wrong or is there a better way to do this?

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)

....stuff

end sub

--
Trefor


Ads