Mail delivery completion event?

  • Thread starter Thread starter Gale Green
  • Start date Start date
G

Gale Green

Hi all.

Outlook 2000.

I have a COM Add-In that performs a variety of tasks when messages are
received in Inbox. Some messages, related to the support function of
one of my VB apps, are processed and then deleted.

I have a module, downloaded from the net somewhere, which enables me
to delete the "new mail" systray icon when Inbox has no unread items,
but currently I have to check this after each message is processed.
So, if I receive a lot of messages which all happen to be of the
process-and-delete type, the icon continually appears and then
disappears, creating a bizarre visual effect with the system tray
continually expanding and contracting.

So, finally, my question: is there a way to know when a mail delivery
is in progress, and/or when it completes, so that I can check for
unread items just the once?

Gale.
 
Try something like this (modified for you Add-In architecture, of course):

Option Explicit
Dim WithEvents objDefaultSendReceive As Outlook.SyncObject

Private Sub Application_Startup()
Dim objNS As Outlook.namespace

Set objNS = Application.GetNamespace("MAPI")
Set objDefaultSendReceive = objNS.SyncObjects.Item("All Accounts")
End Sub

Private Sub Application_Quit()
Set objDefaultSendReceive = Nothing
End Sub

Private Sub objDefaultSendReceive_SyncEnd()
MsgBox "Send/Receive complete."
End Sub

Thanks Eric.

A bit of fiddling and all is now working.

Gale.
 
Back
Top