olInboxItems_ItemAdd and exchange

  • Thread starter Thread starter Jane
  • Start date Start date
J

Jane

Hi, my apologies that I have posted this before, but I never got anywhere
and the problem is getting more urgent so any help is much appreciated.

I have a vbscript that runs in thisoutlooksession under
olInboxItems_ItemAdd(ByVal Item As Object)

This works fine when outlook is connected to a pop3 account, and it works
fine when connected to exchange while outlook is running.

However, if you close outlook (like people do overnight) - when you re-open
it the mails recieved during the closetime dont fire the
olInboxItems_ItemAdd event.

Anyone know why, or even better know what I can do about it ???

Thanks

Jane
 
Items come into the Exchange mailbox as long as the server is running. So
ItemAdd won't fire on those items when you start Outlook because they were
previously added to the Inbox while Outlook was closed.

I usually iterate all the unread items in the Inbox on startup and process
them. Sometimes I add a user property to the items I've processed using CDO
so the user won't see the property to prevent processing items again if the
user leaves them unread.

You are best off posting questions like this in the program_vba group,
that's one of the groups where the developers hang out.
 
Thanks Ken,

I will take your advice and iterate through unread items on startup.......
dont suppose you could give me some pointers how to do that ??

Jane
 
This is Outlook VBA code, where Application is Outlook.Application:

Dim oFolder As Outlook.MAPIFolder
Dim oItems As Outlook.Items
Dim oFilteredItems As Outlook.Items
Dim oMail As Outlook.MailItem

Set oFolder = Application.Session.GetDefaultFolder(olFolderInbox)
Set oItems = oFolder.items
Set oFilteredItems = oItems.Restrict("[UnRead] = " & True)
'now can process items that are unread.
'no checking done here to see if all items are MailItem. That is needed,
'so is error handling
For Each oMail In oFilteredItems
'whatever
Next
 
Thank you very much ken, I will have a go at this today

Jane


Ken Slovak - said:
This is Outlook VBA code, where Application is Outlook.Application:

Dim oFolder As Outlook.MAPIFolder
Dim oItems As Outlook.Items
Dim oFilteredItems As Outlook.Items
Dim oMail As Outlook.MailItem

Set oFolder = Application.Session.GetDefaultFolder(olFolderInbox)
Set oItems = oFolder.items
Set oFilteredItems = oItems.Restrict("[UnRead] = " & True)
'now can process items that are unread.
'no checking done here to see if all items are MailItem. That is needed,
'so is error handling
For Each oMail In oFilteredItems
'whatever
Next




Jane said:
Thanks Ken,

I will take your advice and iterate through unread items on startup.......
dont suppose you could give me some pointers how to do that ??

Jane
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top