PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming How do you reference the mailitem in an Explorer preview pane?

Reply

How do you reference the mailitem in an Explorer preview pane?

 
Thread Tools Rate Thread
Old 26-09-2003, 01:27 AM   #1
Gary
Guest
 
Posts: n/a
Default How do you reference the mailitem in an Explorer preview pane?


Hello,

I would like to know how I could trap or determine programmatically
when a user is reading an email message in the preview pane. In other
words, without double clicking a message, which normally opens an
inspector window to display that email message, I would like to
programmatically determine when a user is just reading the message in
the preview pane. Also, in Outlook 2000, when a user single clicks
another message, that message's body then appears in the preview pane
normally. Is there any event that can tell me when a user is
previewing a message? The closest event is the SelectionChange event
of the Explorer object.

I do know there is an event for the Explorer Object called
SelectionChange and that seems to work. I did a test by putting in a
message box inside this event and sure enough the message box came up
when I browsed to another message (clicked onto a message).

What I want to do is run a program when the user clicks the message. I
have a VB 6 COM Add-in program running perfectly when the user double
clicks a message that opens an inspector window (I declared and
instantiated an object variable of type MailItem that points to the
mail item when a new inspector window opens – code snippet given
below.). However, since an inspector window isn't being opened, I
can't use the same code. I am also only interested in emails in the
inbox when I run my program.


Private Sub oAppInspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)
'When a new Inspector is opened
Set oAppInspector = Inspector
If oAppInspector.CurrentItem.Class = olMail Then 'only Mail items
Set oAppMail = oAppInspector.CurrentItem
End If
End Sub


I also have events for the object variable oAppMail such as Send,
Reply, and Read, which are also working great.

I guess what I am asking is how do you set an object variable of
MailItem type to the currently viewed email message in the preview
pane? Once I have that, I think I can use similar code to what I have
now. However, I don't think there is an active inspector window to use
so I am at loss.

Any help is most appreciated. Thanks.
  Reply With Quote
Old 26-09-2003, 04:28 PM   #2
Ken Slovak - [MVP - Outlook]
Guest
 
Posts: n/a
Default Re: How do you reference the mailitem in an Explorer preview pane?

SelectionChange and the Selection collection are what you get in an
Explorer. Any item that is read in the preview pane fires the Read
event for that item but you'd need to instantiate each member of the
Selection collection and put the items in a selection wrapper class to
fire the event individually for each item.

You can look at the ItemsCB COM addin sample on the Resources page at
www.microeye.com to see an example of an Explorer wrapper. I've used
similar code to wrap Inspectors, Items and so on.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


"Gary" <garyy@globalipgroup.com> wrote in message
news:87390280.0309251627.16e45f06@posting.google.com...
> Hello,
>
> I would like to know how I could trap or determine programmatically
> when a user is reading an email message in the preview pane. In

other
> words, without double clicking a message, which normally opens an
> inspector window to display that email message, I would like to
> programmatically determine when a user is just reading the message

in
> the preview pane. Also, in Outlook 2000, when a user single clicks
> another message, that message's body then appears in the preview

pane
> normally. Is there any event that can tell me when a user is
> previewing a message? The closest event is the SelectionChange event
> of the Explorer object.
>
> I do know there is an event for the Explorer Object called
> SelectionChange and that seems to work. I did a test by putting in a
> message box inside this event and sure enough the message box came

up
> when I browsed to another message (clicked onto a message).
>
> What I want to do is run a program when the user clicks the message.

I
> have a VB 6 COM Add-in program running perfectly when the user

double
> clicks a message that opens an inspector window (I declared and
> instantiated an object variable of type MailItem that points to the
> mail item when a new inspector window opens - code snippet given
> below.). However, since an inspector window isn't being opened, I
> can't use the same code. I am also only interested in emails in the
> inbox when I run my program.
>
>
> Private Sub oAppInspectors_NewInspector(ByVal Inspector As
> Outlook.Inspector)
> 'When a new Inspector is opened
> Set oAppInspector = Inspector
> If oAppInspector.CurrentItem.Class = olMail Then 'only Mail

items
> Set oAppMail = oAppInspector.CurrentItem
> End If
> End Sub
>
>
> I also have events for the object variable oAppMail such as Send,
> Reply, and Read, which are also working great.
>
> I guess what I am asking is how do you set an object variable of
> MailItem type to the currently viewed email message in the preview
> pane? Once I have that, I think I can use similar code to what I

have
> now. However, I don't think there is an active inspector window to

use
> so I am at loss.
>
> Any help is most appreciated. Thanks.



  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off