Re: How do I catch Outlook 2000 MailItem Reply Event

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Russell Mangel (russell_at_tymer.net)
Date: 05/06/04


Date: Wed, 5 May 2004 19:17:07 -0700

Thanks, this explains why I was unable to catch the event when the Outlook
Item is not open.
Now, I have to find some code that wraps all this up... I am a very poor at
VB6, (I use C++/C#).
Do you have VB6 sample (class module, or what ever it's called in VB6)?

Thanks
Russell Mangel
Las Vegas, NV

"Ken Slovak - [MVP - Outlook]" <kenslovak@mvps.org> wrote in message
news:eySt2ZuLEHA.1892@TK2MSFTNGP10.phx.gbl...
> To add to what Eric said, another method of trapping Reply for a mail item
> that isn't opened is to instantiate a MailItem declared WithEvents in a
> SelectionChange event handler for the current Explorer. If you want to
> handle more than one item then you can set up a Selection wrapper class
and
> collection, similar to the Explorer and Inspector wrappers that have been
> posted so many times here.
>
> Any time you want to handle an indeterminate number of possible open
objects
> you can wrap them in class modules and stuff them into a collection. As
long
> as each member class has a WithEvents declaration for a MailItem and is
> instantiated in SelectionChange and removed if not currently in the
> selection in that event you can do precisely that.
>
> So in that circumstance you would not need to trap the Click event of the
> toolbar/menu Reply button, which wouldn't work in any case if the user
user
> a keyboard shortcut to reply to an item in the Explorer or if they used
the
> right-click context menu. The wrapper solution handles all those cases.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Options
> http://www.slovaktech.com/products.htm
>
>
> "Eric Legault [MVP - Outlook]" <elegaultZZZ@REMOVEZZZmvps.org> wrote in
> message news:e2PBtRjLEHA.1272@tk2msftngp13.phx.gbl...
> > Below is the code I am using. When I click the Reply button when a
> message
> > in Outlook is selected, the myMsg_Open button fires and I have a handle
to
> > the new reply message that has not been sent yet. When I click Send, no
> > events fire, which is as it should be. The myMsg_Reply only fires when
> you
> > have an existing email open and click Reply there. Opening existing
> emails
> > of course fires the _Open event.
> >
> > Keep in mind the Reply event is only in the context of an OPEN message.
> If
> > you want to trap a user clicking the Reply button in the main Outlook
> > window, you'd have to trap the Click event of that toolbarbutton: Dim
> > WithEvents objReplyButton As Office.CommandBarButton, Set objReplyButton
=
> > ActiveExplorer.CommandBars.FindControl(, 354). But the message opens
> AFTER
> > the event, so you can't get a handle to it from Click.
> >
> > Option Explicit
> > Dim WithEvents myOlInspectors As Outlook.Inspectors
> > Dim WithEvents myMsg As Outlook.MailItem
> >
> > Private Sub myMsg_Open(Cancel As Boolean)
> >
> > End Sub
> >
> > Private Sub myMsg_Reply(ByVal Response As Object, Cancel As Boolean)
> > MsgBox "Hello world!"
> > End Sub
> >
> > Private Sub myOlInspectors_NewInspector(ByVal Inspector As Inspector)
> > If Inspector.CurrentItem.Class <> olMail Then Exit Sub
> > Set myMsg = Inspector.CurrentItem
> > End Sub
> >
> > Private Sub Application_Startup()
> > Set myOlInspectors = Application.Inspectors
> > End Sub
> >
> > Private Sub Application_Quit()
> > Set myOlInspectors = Nothing
> > Set myMsg = Nothing
> > End Sub
> >
> > --
> > Eric Legault - B.A, MCP, MCSD, Outlook MVP
> > --------------------------------------------------
> > Job: http://www.imaginets.com
> > Blog: http://blogs.officezealot.com/legault/
>
>


Quantcast