Reply/Replyall/Forward Events

G

Guest

Question: I currently have hooked the MailItem Open,reply,reply all, forward
etc and know when a reply is generated from an open Outlook Email. However,
if I reply from the commandbar or right-mouse click the item and reply, I
only get the open event. How do I know it is a reply/reply all or forward
and not a "New Item"?

Outlook 2002 SP2
 
G

Guest

Hook the Inspector Object for Mail Items below:
Implements IDTExtensibility2

'---Object variables for Event procedures declared in OutAddIn class module
Public WithEvents golApp As Outlook.Application
Public WithEvents objNS As Outlook.NameSpace
Public WithEvents objExpl As Outlook.Explorer
Public WithEvents colExpl As Outlook.Explorers
Public WithEvents objInsp As Outlook.Inspector
Public WithEvents colInsp As Outlook.Inspectors
Public WithEvents objMailItem As Outlook.MailItem
Public WithEvents objPostItem As Outlook.PostItem
Public WithEvents objContactItem As Outlook.ContactItem
Public WithEvents objDistListItem As Outlook.DistListItem
Public WithEvents objApptItem As Outlook.AppointmentItem
Public WithEvents objTaskItem As Outlook.TaskItem
Public WithEvents objJournalItem As Outlook.JournalItem

Private Sub colInsp_NewInspector(ByVal Inspector As Outlook.Inspector)
On Error Resume Next

Select Case Inspector.CurrentItem.Class
Case olMail
Set objMailItem = Inspector.CurrentItem
Set objInsp = Inspector
mvarWordEditor = objInsp.IsWordMail
Case olContact
Set objContactItem = Inspector.CurrentItem
Set objInsp = Inspector
Case olAppointment
Set objApptItem = Inspector.CurrentItem
Set objInsp = Inspector
End Select
end sub

I have code for OPen,Write,Save,Forward,Reply,ReplyALL. If an email is open
and the user hits replay, then the reply event fires and I can do something
to the message. If however, the email is not open and the user hits reply
from the toolbar or right-mouse click on the message I only get the Open
event.

I suspose the question would be "should I be hooking the commandbar
Reply/ReplyALL forward command buttons?"

Veriosn: Outlook 2002 SP3. VB6 AddIn.

Thanks

Blair


Dmitry Streblechenko said:
Works just fine here. How do you hook up the events?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
D

Dmitry Streblechenko

Of course, your events will be called only for the items open in an
inspector. What you need is to track the Explorer.SelectionChange event and
hook up the selected items.
Another problem is that you only support only one inspector. If more than
one item is open, you'll only receive events from the second item.
See ItemsCB at http://www.microeye.com and
http://www.slovaktech.com/code_samples.htm#InspectorWrapper

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Blair Nygren said:
Hook the Inspector Object for Mail Items below:
Implements IDTExtensibility2

'---Object variables for Event procedures declared in OutAddIn class
module
Public WithEvents golApp As Outlook.Application
Public WithEvents objNS As Outlook.NameSpace
Public WithEvents objExpl As Outlook.Explorer
Public WithEvents colExpl As Outlook.Explorers
Public WithEvents objInsp As Outlook.Inspector
Public WithEvents colInsp As Outlook.Inspectors
Public WithEvents objMailItem As Outlook.MailItem
Public WithEvents objPostItem As Outlook.PostItem
Public WithEvents objContactItem As Outlook.ContactItem
Public WithEvents objDistListItem As Outlook.DistListItem
Public WithEvents objApptItem As Outlook.AppointmentItem
Public WithEvents objTaskItem As Outlook.TaskItem
Public WithEvents objJournalItem As Outlook.JournalItem

Private Sub colInsp_NewInspector(ByVal Inspector As Outlook.Inspector)
On Error Resume Next

Select Case Inspector.CurrentItem.Class
Case olMail
Set objMailItem = Inspector.CurrentItem
Set objInsp = Inspector
mvarWordEditor = objInsp.IsWordMail
Case olContact
Set objContactItem = Inspector.CurrentItem
Set objInsp = Inspector
Case olAppointment
Set objApptItem = Inspector.CurrentItem
Set objInsp = Inspector
End Select
end sub

I have code for OPen,Write,Save,Forward,Reply,ReplyALL. If an email is
open
and the user hits replay, then the reply event fires and I can do
something
to the message. If however, the email is not open and the user hits reply
from the toolbar or right-mouse click on the message I only get the Open
event.

I suspose the question would be "should I be hooking the commandbar
Reply/ReplyALL forward command buttons?"

Veriosn: Outlook 2002 SP3. VB6 AddIn.

Thanks

Blair
 
G

Guest

Thanks for the assistance on the one inspector issue. I inherited the code
and realized that it only worked on the one item.

However, how is the explorer.selectionChange event going to help me with the
"Reply" right mouse click or "reply" pressed from the toolbar. I trap the
selectionchange event which gives me the new item selected but I don't get
anything if "Reply" via right mouse click? Any additional insight?

Thanks

Blair
 
K

Ken Slovak - [MVP - Outlook]

What you will need is a Selection wrapper, similar to the Inspector wrapper
Dmitry pointed you to.

When SelectionChange fires you clear out your old collection of Selection
class wrappers and iterate the Selection collection and add each selected
item to your Selection wrapper collection. In the wrapper class you would
instantiate each item type you want to handle WithEvents so you can handle
its events. Then you will be able to handle the Reply, etc. events when
those buttons/menu items are clicked in the Explorer.

It sounds complicated but works just the same as that Inspector wrapper
example.

I've used Selection, Items, CommandBarButtons and other similar wrapper
classes and collections in many addins where I had to handle dynamic
collections of items.
 

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

Top