![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]()
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 |
#3
|
|||
|
|||
![]()
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 |
#4
|
|||
|
|||
![]()
Putting your code in ThisOutlookSession was the right thing to do.
The problem is that you have duplicate declarations for InputFolder. Once as Items and once as MAPIFolder. You need to use two separate objects. It will be easiest to change the name of the MAPIFolder object. You will then need to add a statement to instantiate the Items object (InputFolder). Also, there seems to be no purpose for the local olMail object in the Application_Startup procedure. -- 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 news ![]() 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 "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. "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 |
#5
|
|||
|
|||
![]()
Sue,
Sorry you lost me there. "Once as Items..." which line? "Once as MAPIFolder." Dim InputFolder As Outlook.MAPIFolder Set InputFolder = olNS.Folders("Mailbox - Partners").Folders("Order Notification") The following in start up Dim olMail As Items Set olMail = InputFolder.Items are related to Private Sub InputFolder_ItemAdd(ByVal Item As Object) Dim MessageText As String Dim ItemReference As Integer For ItemReference = olMail.Count To 1 Step -1 On Error Resume Next MessageText = olMail(ItemReference).Body If Err 0 Then MessageText = "" On Error GoTo 0 .. .. olMail(ItemReference).UnRead = False olMail(ItemReference).Move ProcessedFolder .. .. -- Trefor "Sue Mosher [MVP-Outlook]" wrote: Putting your code in ThisOutlookSession was the right thing to do. The problem is that you have duplicate declarations for InputFolder. Once as Items and once as MAPIFolder. You need to use two separate objects. It will be easiest to change the name of the MAPIFolder object. You will then need to add a statement to instantiate the Items object (InputFolder). Also, there seems to be no purpose for the local olMail object in the Application_Startup procedure. -- 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 news ![]() 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 "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. "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 |
#6
|
|||
|
|||
![]()
"Once as Items..."
which line? In the declarations section: Private WithEvents InputFolder As Items In Application_Startup: Dim InputFolder As Outlook.MAPIFolder In your Items.ItemAdd event handler, you should be processing Item, the new item added to the folder, e.g. instead of MessageText = olMail(ItemReference).Body you'd get rid of the For loop and simply use MessageText = Item.Body -- 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 ... Sue, Sorry you lost me there. "Once as Items..." which line? "Once as MAPIFolder." Dim InputFolder As Outlook.MAPIFolder Set InputFolder = olNS.Folders("Mailbox - Partners").Folders("Order Notification") The following in start up Dim olMail As Items Set olMail = InputFolder.Items are related to Private Sub InputFolder_ItemAdd(ByVal Item As Object) Dim MessageText As String Dim ItemReference As Integer For ItemReference = olMail.Count To 1 Step -1 On Error Resume Next MessageText = olMail(ItemReference).Body If Err 0 Then MessageText = "" On Error GoTo 0 . . olMail(ItemReference).UnRead = False olMail(ItemReference).Move ProcessedFolder . . -- Trefor "Sue Mosher [MVP-Outlook]" wrote: Putting your code in ThisOutlookSession was the right thing to do. The problem is that you have duplicate declarations for InputFolder. Once as Items and once as MAPIFolder. You need to use two separate objects. It will be easiest to change the name of the MAPIFolder object. You will then need to add a statement to instantiate the Items object (InputFolder). Also, there seems to be no purpose for the local olMail object in the Application_Startup procedure. -- 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 news ![]() 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 "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. "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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
NewMailEx Code runs only once... | Rafael[_2_] | Outlook - Using Forms | 0 | September 9th 07 03:10 AM |
Sending mail from NewMailEx deletes the mail from the Inbox | Ron | Outlook and VBA | 1 | January 10th 07 07:40 PM |
newmailex - messageclass change not displayed message opened | spareway | Add-ins for Outlook | 4 | January 3rd 07 11:12 PM |
How to fire NewMail&NewMailEx Event? | baryon | Outlook - General Queries | 0 | August 17th 06 04:31 PM |
NewMailEx vs. ItemAdd | Mark Rae | Outlook and VBA | 14 | June 15th 06 03:07 PM |