PC Review


Reply
Thread Tools Rate Thread

Problem using NewMailEx

 
 
Trefor
Guest
Posts: n/a
 
      29th May 2008
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
 
Reply With Quote
 
 
 
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      29th May 2008
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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

 
Reply With Quote
 
 
 
 
Trefor
Guest
Posts: n/a
 
      29th May 2008
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> > 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

>

 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      29th May 2008
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" <(E-Mail Removed)> wrote in message news(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> > 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

>>

 
Reply With Quote
 
Trefor
Guest
Posts: n/a
 
      29th May 2008
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" <(E-Mail Removed)> wrote in message news(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> >> > 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
> >>

>

 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      29th May 2008
> "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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message news(E-Mail Removed)...
>> > 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> >> > 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
>> >>

>>

 
Reply With Quote
 
Trefor
Guest
Posts: n/a
 
      30th May 2008
Sue,

I original wrote the code to be fired manually, then reading comments like
"more than 16 emails will not trigger this code" it seemed to make sense to
let the code clean up whatever it found in the folder.

I obviously still don’t understand these commands.

I assumed this meant look for new Items (emails) in a particular folder
(InputFolder)

Private WithEvents InputFolder As Items

This is telling Outlook that InputFolder is an MAPIFolder, so this is about
the folder not the Item/email?

Dim InputFolder As Outlook.MAPIFolder


Are you saying I can’t clean up all emails found in the folder? Only the one
that has just arrived? I am really keen at this stage to have code that will
work on whatever it finds in this directory, is there a better way of doing
this?

--
Trefor


"Sue Mosher [MVP-Outlook]" wrote:

> > "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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message news(E-Mail Removed)...
> >> > 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> >> >> > 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
> >> >>
> >>

>

 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      30th May 2008
If you want to process all unprocessed items in the folder when Items.ItemAdd fires, that's fine. But don't do it by processing *every* item. That's very inefficient. Use Items.Find or Items.Restrict to filter the Items collection so that you process only items that need processing.

The problem with InputFolder is two-fold: (a) You're never instantiating the module-level object that is supposed to fire the events. You're only instantiating the variable that is local to the Application_Startup event handler. (b) Even if you take out the Dim statement in Application_Startup, you'd still have a problem, because the statement that instantiates InputFolder returns a MAPIFolder object, not an Items collection. Therefore, you need to take out that extraneous Dim statement and fix the Set InputFolder statement so that it matches the Private WithEvents declaration.
--
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Sue,
>
> I original wrote the code to be fired manually, then reading comments like
> "more than 16 emails will not trigger this code" it seemed to make sense to
> let the code clean up whatever it found in the folder.
>
> I obviously still don’t understand these commands.
>
> I assumed this meant look for new Items (emails) in a particular folder
> (InputFolder)
>
> Private WithEvents InputFolder As Items
>
> This is telling Outlook that InputFolder is an MAPIFolder, so this is about
> the folder not the Item/email?
>
> Dim InputFolder As Outlook.MAPIFolder
>
>
> Are you saying I can’t clean up all emails found in the folder? Only the one
> that has just arrived? I am really keen at this stage to have code that will
> work on whatever it finds in this directory, is there a better way of doing
> this?
>
> --
> Trefor
>
>
> "Sue Mosher [MVP-Outlook]" wrote:
>
>> > "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


>>
>>
>> "Trefor" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> > 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" <(E-Mail Removed)> wrote in message news(E-Mail Removed)...
>> >> > 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> >> >> > 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
>> >> >>
>> >>

>>

 
Reply With Quote
 
Trefor
Guest
Posts: n/a
 
      30th May 2008
Items.Find – Can this be used to find text in the body of an email? I have
already narrowed the Items I am looking at down to as few as possible by
using a rule. The only way I know now which emails I want (or not) is by
check to see if there are certain words in the body text.

To do this I have used this:

For ItemReference = olMail.Count To 1 Step -1

MessageText = olMail(ItemReference).Body

If InStr(MessageText, "my text") > 0 Then
‘ Then Parse MessageText to get the various bits of info I need

Sue as for the rest of your comments I don’t mean to be rude, but “you speak
with forked tongue ”. I am not a professional developer and have never done
any coding in Outlook and you clearly are one of the guru’s in this area.

I have made some changes that sort of work and have include the full sub
routines below:


I realize NewMailEx is looking at my mailbox and not the shared mailbox, but
it is a way of periodically checking the shared mailbox. I feel you cringing
already

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Call ProcessEmails
End Sub

Private Sub Application_Startup()
Call ProcessEmails
End Sub

Private Sub ProcessEmails()

Dim DeletedFolder As Outlook.MAPIFolder
Dim olNS As NameSpace
Dim InputFolder As Outlook.MAPIFolder
Dim ProcessedFolder As Outlook.MAPIFolder


Set olNS = Outlook.Application.GetNamespace("MAPI")
Set InputFolder = olNS.Folders("Mailbox - Partners").Folders("Order
Notification")
Set ProcessedFolder = olNS.Folders("Mailbox - Partners").Folders("Order
Notification Processed")
Set DeletedFolder = olNS.Folders("Mailbox - Partners").Folders("Deleted
Items")

Dim MessageText As String
Dim ItemReference As Integer
Dim olMail As Items

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


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

If InStr(MessageText, "my text ") > 0 Then
' Parse this email.
Call ParseEmail(MessageText, GoodReturn)
BookingElement(18) = olMail(ItemReference).ReceivedTime

If GoodReturn Then
Call WriteTransactionFile(GoodReturn)
If GoodReturn Then
olMail(ItemReference).UnRead = False
olMail(ItemReference).Move ProcessedFolder
On Error Resume Next
olMail(ItemReference).UnRead = False ' Per suggestion
from Ken Slovak re maybe having to set this twice.
On Error GoTo 0
End If
End If
Else
olMail(ItemReference).Move DeletedFolder
End If
Next ItemReference

Set InputFolder = Nothing
Set ProcessedFolder = Nothing
Set olNS = Nothing
Set olMail = Nothing
End Sub


--
Trefor


"Sue Mosher [MVP-Outlook]" wrote:

> If you want to process all unprocessed items in the folder when Items.ItemAdd fires, that's fine. But don't do it by processing *every* item. That's very inefficient. Use Items.Find or Items.Restrict to filter the Items collection so that you process only items that need processing.
>
> The problem with InputFolder is two-fold: (a) You're never instantiating the module-level object that is supposed to fire the events. You're only instantiating the variable that is local to the Application_Startup event handler. (b) Even if you take out the Dim statement in Application_Startup, you'd still have a problem, because the statement that instantiates InputFolder returns a MAPIFolder object, not an Items collection. Therefore, you need to take out that extraneous Dim statement and fix the Set InputFolder statement so that it matches the Private WithEvents declaration.
> --
> 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> > Sue,
> >
> > I original wrote the code to be fired manually, then reading comments like
> > "more than 16 emails will not trigger this code" it seemed to make sense to
> > let the code clean up whatever it found in the folder.
> >
> > I obviously still don’t understand these commands.
> >
> > I assumed this meant look for new Items (emails) in a particular folder
> > (InputFolder)
> >
> > Private WithEvents InputFolder As Items
> >
> > This is telling Outlook that InputFolder is an MAPIFolder, so this is about
> > the folder not the Item/email?
> >
> > Dim InputFolder As Outlook.MAPIFolder
> >
> >
> > Are you saying I can’t clean up all emails found in the folder? Only the one
> > that has just arrived? I am really keen at this stage to have code that will
> > work on whatever it finds in this directory, is there a better way of doing
> > this?
> >
> > --
> > Trefor
> >
> >
> > "Sue Mosher [MVP-Outlook]" wrote:
> >
> >> > "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

>
> >>
> >>
> >> "Trefor" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> >> > 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" <(E-Mail Removed)> wrote in message news(E-Mail Removed)...
> >> >> > 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> >> >> >> > 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
> >> >> >>
> >> >>
> >>

>

 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      30th May 2008
> Items.Find – Can this be used to find text in the body of an email?

No, but Restrict can. However, if you already have a rule moving items to be processed into a particular folder and code moving them out after they're processed, that may sufficient if there aren't too many items. Let me know if you want to try using Restrict.

> I realize NewMailEx is looking at my mailbox and not the shared mailbox, but
> it is a way of periodically checking the shared mailbox. I feel you cringing
> already


Yes, that makes me cringe, because it means that if you don't receive any messages in your own mailbox for a long period of time, those in the other mailbox will go unprocessed. If you want to pursue using the Items.ItemAdd event, let me know, as it looks like we'll need to go over some VBA basics like working with event-enabled variables that aren't related specifically to Outlook code.

--
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Items.Find – Can this be used to find text in the body of an email? I have
> already narrowed the Items I am looking at down to as few as possible by
> using a rule. The only way I know now which emails I want (or not) is by
> check to see if there are certain words in the body text.
>
> To do this I have used this:
>
> For ItemReference = olMail.Count To 1 Step -1
>
> MessageText = olMail(ItemReference).Body
>
> If InStr(MessageText, "my text") > 0 Then
> ‘ Then Parse MessageText to get the various bits of info I need
>
> Sue as for the rest of your comments I don’t mean to be rude, but “you speak
> with forked tongue ”. I am not a professional developer and have never done
> any coding in Outlook and you clearly are one of the guru’s in this area.
>
> I have made some changes that sort of work and have include the full sub
> routines below:
>
>
> I realize NewMailEx is looking at my mailbox and not the shared mailbox, but
> it is a way of periodically checking the shared mailbox. I feel you cringing
> already
>
> Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
> Call ProcessEmails
> End Sub
>
> Private Sub Application_Startup()
> Call ProcessEmails
> End Sub
>
> Private Sub ProcessEmails()
>
> Dim DeletedFolder As Outlook.MAPIFolder
> Dim olNS As NameSpace
> Dim InputFolder As Outlook.MAPIFolder
> Dim ProcessedFolder As Outlook.MAPIFolder
>
>
> Set olNS = Outlook.Application.GetNamespace("MAPI")
> Set InputFolder = olNS.Folders("Mailbox - Partners").Folders("Order
> Notification")
> Set ProcessedFolder = olNS.Folders("Mailbox - Partners").Folders("Order
> Notification Processed")
> Set DeletedFolder = olNS.Folders("Mailbox - Partners").Folders("Deleted
> Items")
>
> Dim MessageText As String
> Dim ItemReference As Integer
> Dim olMail As Items
>
> ' Get reference to items in folder
> Set olMail = InputFolder.Items
>
>
> 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
>
> If InStr(MessageText, "my text ") > 0 Then
> ' Parse this email.
> Call ParseEmail(MessageText, GoodReturn)
> BookingElement(18) = olMail(ItemReference).ReceivedTime
>
> If GoodReturn Then
> Call WriteTransactionFile(GoodReturn)
> If GoodReturn Then
> olMail(ItemReference).UnRead = False
> olMail(ItemReference).Move ProcessedFolder
> On Error Resume Next
> olMail(ItemReference).UnRead = False ' Per suggestion
> from Ken Slovak re maybe having to set this twice.
> On Error GoTo 0
> End If
> End If
> Else
> olMail(ItemReference).Move DeletedFolder
> End If
> Next ItemReference
>
> Set InputFolder = Nothing
> Set ProcessedFolder = Nothing
> Set olNS = Nothing
> Set olMail = Nothing
> End Sub
>
>
> --
> Trefor
>
>
> "Sue Mosher [MVP-Outlook]" wrote:
>
>> If you want to process all unprocessed items in the folder when Items.ItemAdd fires, that's fine. But don't do it by processing *every* item. That's very inefficient. Use Items.Find or Items.Restrict to filter the Items collection so that you process only items that need processing.
>>
>> The problem with InputFolder is two-fold: (a) You're never instantiating the module-level object that is supposed to fire the events. You're only instantiating the variable that is local to the Application_Startup event handler. (b) Even if you take out the Dim statement in Application_Startup, you'd still have a problem, because the statement that instantiates InputFolder returns a MAPIFolder object, not an Items collection. Therefore, you need to take out that extraneous Dim statement and fix the Set InputFolder statement so that it matches the Private WithEvents declaration.
>>
>> "Trefor" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> > Sue,
>> >
>> > I original wrote the code to be fired manually, then reading comments like
>> > "more than 16 emails will not trigger this code" it seemed to make sense to
>> > let the code clean up whatever it found in the folder.
>> >
>> > I obviously still don’t understand these commands.
>> >
>> > I assumed this meant look for new Items (emails) in a particular folder
>> > (InputFolder)
>> >
>> > Private WithEvents InputFolder As Items
>> >
>> > This is telling Outlook that InputFolder is an MAPIFolder, so this is about
>> > the folder not the Item/email?
>> >
>> > Dim InputFolder As Outlook.MAPIFolder
>> >
>> >
>> > Are you saying I can’t clean up all emails found in the folder? Only the one
>> > that has just arrived? I am really keen at this stage to have code that will
>> > work on whatever it finds in this directory, is there a better way of doing
>> > this?
>> >
>> > --
>> > Trefor
>> >
>> >
>> > "Sue Mosher [MVP-Outlook]" wrote:
>> >
>> >> > "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

>>
>> >>
>> >>
>> >> "Trefor" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> >> > 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" <(E-Mail Removed)> wrote in message news(E-Mail Removed)...
>> >> >> > 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> >> >> >> > 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
>> >> >> >>
>> >> >>
>> >>

>>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Sending mail from NewMailEx deletes the mail from the Inbox Ken Slovak - [MVP - Outlook] Microsoft Outlook VBA Programming 0 10th Jan 2007 08:40 PM
How to fire NewMail&NewMailEx Event? baryon Microsoft Outlook 0 17th Aug 2006 04:31 PM
NewMailEx vs. ItemAdd Mark Rae Microsoft Outlook VBA Programming 14 15th Jun 2006 03:07 PM
NewMailEx not returning a string of all entry IDs Yuhua Li via OfficeKB.com Microsoft Outlook Program Addins 0 25th Mar 2005 06:21 PM
NewMailEx Stops Firing David B. Bitton Microsoft Outlook Program Addins 0 24th Jun 2004 05:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:14 AM.