Chaning MessageClass with Preview Pane

Status
Not open for further replies.
Z

ZG1qYW1lcw

I'm trying to change MessageClass when an item is opened so as to open a

custom form. My code works fine when the Preview Pane is closed; it doesn't

work when the pane is open. I've tried changing the form, clearing forms

cache, etc.; I'm sure it's not a form problem. I've tested and tried it many

times -- the behavior is that it works when Preview Pane is closed, and opens

the default IPM.Note when the Preview Pane is open. (If anyone is curious,

my ultimate goal is to provide a preview tab where all text in the message is

changed to an easy-to-read font, but not change the message permanently.)

Here's my code:

'CONNECTION CODE

Option Explicit

Dim WithEvents objInsps As Outlook.Inspectors

Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal

ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As

Object, custom() As Variant)

Set objInsps = Application.Inspectors

AddInInst.object = Me

End Sub

Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As

AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)

Set objInsps = Nothing

End Sub

Private Sub objInsps_NewInspector(ByVal currInsp As Inspector)

Dim ci As New clsInspectors

If currInsp.CurrentItem.Class = olMail Then

If currInsp.CurrentItem.MessageClass = "IPM.Note" Or

currInsp.CurrentItem.MessageClass = "IPM.Note.Preview" Then

If currInsp.CurrentItem.EntryID <> vbNullString Then 'Sent

Set ci = InspColl.Add(currInsp,

currInsp.CurrentItem.entryid) 'collection of clsInspectors

ci.IID = currInsp.CurrentItem.EntryID

ci.FirstActivation = True

End If

End If

End If

End Sub

'CLSINSPECTORS

Option Explicit

Public WithEvents currInsp As Inspector

Public IID As String

Public FirstActivation As Boolean

Private Sub currInsp_Activate()

If FirstActivation Then

currInsp.CurrentItem.MessageClass = "IPM.Note.Preview"

currInsp.CurrentItem.Save

'The custom form contains a preview control on a tab called Preview,

which I populate here

'If the preview pane of the explorer from which I opened the item is

visible, currInsp.ModifiedFormPages("Preview") returns Nothing

FirstActivation = False

End If

End Sub

Private Sub currInsp_Close()

currInsp.CurrentItem.MessageClass = "IPM.Note"

currInsp.CurrentItem.Save

InspColl.Remove IID

End Sub

Thanks,

Dave James
 
Forgot to mention, OL2003 SP3.

"dmjames" wrote:


> I'm trying to change MessageClass when an item is opened so as to open a
> custom form. My code works fine when the Preview Pane is closed; it doesn't
> work when the pane is open. I've tried changing the form, clearing forms
> cache, etc.; I'm sure it's not a form problem. I've tested and tried it many
> times -- the behavior is that it works when Preview Pane is closed, and opens
> the default IPM.Note when the Preview Pane is open. (If anyone is curious,
> my ultimate goal is to provide a preview tab where all text in the message is
> changed to an easy-to-read font, but not change the message permanently.)

> Here's my code:

> 'CONNECTION CODE

> Option Explicit

> Dim WithEvents objInsps As Outlook.Inspectors

> Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal
> ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As
> Object, custom() As Variant)
> Set objInsps = Application.Inspectors
> AddInInst.object = Me
> End Sub

> Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As
> AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
> Set objInsps = Nothing
> End Sub

> Private Sub objInsps_NewInspector(ByVal currInsp As Inspector)
> Dim ci As New clsInspectors
> If currInsp.CurrentItem.Class = olMail Then
> If currInsp.CurrentItem.MessageClass = "IPM.Note" Or
> currInsp.CurrentItem.MessageClass = "IPM.Note.Preview" Then
> If currInsp.CurrentItem.EntryID <> vbNullString Then 'Sent
> Set ci = InspColl.Add(currInsp,
> currInsp.CurrentItem.entryid) 'collection of clsInspectors
> ci.IID = currInsp.CurrentItem.EntryID
> ci.FirstActivation = True
> End If
> End If
> End If
> End Sub

> 'CLSINSPECTORS

> Option Explicit

> Public WithEvents currInsp As Inspector
> Public IID As String
> Public FirstActivation As Boolean

> Private Sub currInsp_Activate()
> If FirstActivation Then
> currInsp.CurrentItem.MessageClass = "IPM.Note.Preview"
> currInsp.CurrentItem.Save
> 'The custom form contains a preview control on a tab called Preview,
> which I populate here
> 'If the preview pane of the explorer from which I opened the item is
> visible, currInsp.ModifiedFormPages("Preview") returns Nothing
> FirstActivation = False
> End If
> End Sub

> Private Sub currInsp_Close()
> currInsp.CurrentItem.MessageClass = "IPM.Note"
> currInsp.CurrentItem.Save
> InspColl.Remove IID
> End Sub

> Thanks,

> Dave James
 
NewInspector() won't help you at all for the preview pane, that's for items

that are being opened, not previewed. You need to handle

Explorer.SelectionChange() for the ActiveExplorer to know what is now

selected and in the preview pane. You would work with the Selection

collection.

Previewing custom forms in the preview pane won't work though, they are

blocked from previewing. You could change the MessageClass and save the item

to preserve the change, but for a custom form you'd just end up with the

preview pane showing the "can't show this message" warning.

"dmjames" <dmjames> wrote in message

news:37FEE281-4404-42C5-8CC1-2433F88521AF@microsoft.com...
> Forgot to mention, OL2003 SP3.

> "dmjames" wrote:
>
> > I'm trying to change MessageClass when an item is opened so as to open a
> > custom form. My code works fine when the Preview Pane is closed; it
> > doesn't
> > work when the pane is open. I've tried changing the form, clearing forms
> > cache, etc.; I'm sure it's not a form problem. I've tested and tried it
> > many
> > times -- the behavior is that it works when Preview Pane is closed, and
> > opens
> > the default IPM.Note when the Preview Pane is open. (If anyone is
> > curious,
> > my ultimate goal is to provide a preview tab where all text in the
> > message is
> > changed to an easy-to-read font, but not change the message permanently.)
>

>> Here's my code:
>

>> 'CONNECTION CODE
>

>> Option Explicit
>

>> Dim WithEvents objInsps As Outlook.Inspectors
>

>> Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal
> > ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As
> > Object, custom() As Variant)
> > Set objInsps = Application.Inspectors
> > AddInInst.object = Me
> > End Sub
>

>> Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As
> > AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
> > Set objInsps = Nothing
> > End Sub
>

>
>> Private Sub objInsps_NewInspector(ByVal currInsp As Inspector)
> > Dim ci As New clsInspectors
> > If currInsp.CurrentItem.Class = olMail Then
> > If currInsp.CurrentItem.MessageClass = "IPM.Note" Or
> > currInsp.CurrentItem.MessageClass = "IPM.Note.Preview" Then
> > If currInsp.CurrentItem.EntryID <> vbNullString Then 'Sent
> > Set ci = InspColl.Add(currInsp,
> > currInsp.CurrentItem.entryid) 'collection of clsInspectors
> > ci.IID = currInsp.CurrentItem.EntryID
> > ci.FirstActivation = True
> > End If
> > End If
> > End If
> > End Sub
>

>> 'CLSINSPECTORS
>

>> Option Explicit
>

>> Public WithEvents currInsp As Inspector
> > Public IID As String
> > Public FirstActivation As Boolean
>

>> Private Sub currInsp_Activate()
> > If FirstActivation Then
> > currInsp.CurrentItem.MessageClass = "IPM.Note.Preview"
> > currInsp.CurrentItem.Save
> > 'The custom form contains a preview control on a tab called
> > Preview,
> > which I populate here
> > 'If the preview pane of the explorer from which I opened the item
> > is
> > visible, currInsp.ModifiedFormPages("Preview") returns Nothing
> > FirstActivation = False
> > End If
> > End Sub
>

>> Private Sub currInsp_Close()
> > currInsp.CurrentItem.MessageClass = "IPM.Note"
> > currInsp.CurrentItem.Save
> > InspColl.Remove IID
> > End Sub
>

>> Thanks,
>

>> Dave James
 
Thanks for the info, but maybe I wasn't completely clear. What I want to do

is change MessageClass when an item is opened and change it back when it's

closed. I don't care about the Preview Pane, except that when it's open it

appears to "lock" the item in some way and prevent the custom form from being

used. If I close the Preview Pane my code works as expected, but it should

work whether or not the Preview Pane is open.

Given this, is trapping SelectionChange() still the answer or is there

another way to "unlock" the item being opened?

Thanks again,

Dave James
wrote:


> NewInspector() won't help you at all for the preview pane, that's for items
> that are being opened, not previewed. You need to handle
> Explorer.SelectionChange() for the ActiveExplorer to know what is now
> selected and in the preview pane. You would work with the Selection
> collection.

> Previewing custom forms in the preview pane won't work though, they are
> blocked from previewing. You could change the MessageClass and save the item
> to preserve the change, but for a custom form you'd just end up with the
> preview pane showing the "can't show this message" warning.

> >

>

> "dmjames" <dmjames> wrote in message
> news:37FEE281-4404-42C5-8CC1-2433F88521AF@microsoft.com...
> > Forgot to mention, OL2003 SP3.
> > "dmjames" wrote:
> >
> >> I'm trying to change MessageClass when an item is opened so as to open a
> >> custom form. My code works fine when the Preview Pane is closed; it
> >> doesn't
> >> work when the pane is open. I've tried changing the form, clearing forms
> >> cache, etc.; I'm sure it's not a form problem. I've tested and tried it
> >> many
> >> times -- the behavior is that it works when Preview Pane is closed, and
> >> opens
> >> the default IPM.Note when the Preview Pane is open. (If anyone is
> >> curious,
> >> my ultimate goal is to provide a preview tab where all text in the
> >> message is
> >> changed to an easy-to-read font, but not change the message permanently.)
> >
> >> Here's my code:
> >
> >> 'CONNECTION CODE
> >
> >> Option Explicit
> >
> >> Dim WithEvents objInsps As Outlook.Inspectors
> >
> >> Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal
> >> ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As
> >> Object, custom() As Variant)
> >> Set objInsps = Application.Inspectors
> >> AddInInst.object = Me
> >> End Sub
> >
> >> Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As
> >> AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
> >> Set objInsps = Nothing
> >> End Sub
> >
> >
> >> Private Sub objInsps_NewInspector(ByVal currInsp As Inspector)
> >> Dim ci As New clsInspectors
> >> If currInsp.CurrentItem.Class = olMail Then
> >> If currInsp.CurrentItem.MessageClass = "IPM.Note" Or
> >> currInsp.CurrentItem.MessageClass = "IPM.Note.Preview" Then
> >> If currInsp.CurrentItem.EntryID <> vbNullString Then 'Sent
> >> Set ci = InspColl.Add(currInsp,
> >> currInsp.CurrentItem.entryid) 'collection of clsInspectors
> >> ci.IID = currInsp.CurrentItem.EntryID
> >> ci.FirstActivation = True
> >> End If
> >> End If
> >> End If
> >> End Sub
> >
> >> 'CLSINSPECTORS
> >
> >> Option Explicit
> >
> >> Public WithEvents currInsp As Inspector
> >> Public IID As String
> >> Public FirstActivation As Boolean
> >
> >> Private Sub currInsp_Activate()
> >> If FirstActivation Then
> >> currInsp.CurrentItem.MessageClass = "IPM.Note.Preview"
> >> currInsp.CurrentItem.Save
> >> 'The custom form contains a preview control on a tab called
> >> Preview,
> >> which I populate here
> >> 'If the preview pane of the explorer from which I opened the item
> >> is
> >> visible, currInsp.ModifiedFormPages("Preview") returns Nothing
> >> FirstActivation = False
> >> End If
> >> End Sub
> >
> >> Private Sub currInsp_Close()
> >> currInsp.CurrentItem.MessageClass = "IPM.Note"
> >> currInsp.CurrentItem.Save
> >> InspColl.Remove IID
> >> End Sub
> >
> >> Thanks,
> >
> >> Dave James


>
 
I don't know about the item being locked, I've never run into that. But

SelectionChange() is still the only way to know when a selection is changed

and to what.

"dmjames" <dmjames> wrote in message

news:B4575B01-3BC8-4AAE-AC2D-85460CC8FAA5@microsoft.com...
> Thanks for the info, but maybe I wasn't completely clear. What I want to
> do
> is change MessageClass when an item is opened and change it back when it's
> closed. I don't care about the Preview Pane, except that when it's open
> it
> appears to "lock" the item in some way and prevent the custom form from
> being
> used. If I close the Preview Pane my code works as expected, but it
> should
> work whether or not the Preview Pane is open.

> Given this, is trapping SelectionChange() still the answer or is there
> another way to "unlock" the item being opened?

> Thanks again,

> Dave James
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
L Applying new form to existing contacts -- MessageClass Outlook VBA and Custom Forms 3
M How to automatically refresh an appointment windows after changing the MessageClass property ? Outlook VBA and Custom Forms 4
e_a_g_l_e_p_i Gmail in Outlook 2010 preview issue Using Outlook 4
R Call a Public Sub when a Flag is clicked on in the Message Preview pane Outlook VBA and Custom Forms 1
P Categorise emails on sending - macro not working in Preview mode Using Outlook 1
T Outlook 2016 mp3 attach "this file cannot be preview because there is no previewer installed for it" Using Outlook 1
H What Controls what is shown in the preview pane Outlook VBA and Custom Forms 1
B Auto Preview Attachment in Inspector Reading Pane Outlook VBA and Custom Forms 1
A OL16 C2R attachment preview fails Using Outlook 8
Z Importing PST files from Outlook 07 to Outlook mac Preview Using Outlook 1
I Outlook 2016 Preview Address Book Options Using Outlook 2
Diane Poremsky Outlook 2016 Preview Using Outlook 4
Diane Poremsky Disable Live Preview in Outlook and Word Using Outlook 0
Diane Poremsky New Office365 Feature: URL Preview in OWA Using Outlook 0
J Copy email from preview pane with headers Outlook VBA and Custom Forms 4
1Firefly Outlook 2013 Converstation preview does not show my last reply Exchange Server Administration 1
L Sort bar at top of inbox preview outlook 2013 Using Outlook 1
Y (Shared Folder) Using the preview pane to open and close a fax, without opening the email itself Using Outlook 1
A Possible to modify people preview window? Using Outlook 1
B Outlook 2010 won't preview Office attachments Using Outlook 3
D Use Outlook 2003 embedded imaged cannot print from the mail preview list Using Outlook 4
M Estimated time in preview bar. Using Outlook 1
E Blank Print Preview when access via the Quick Access toolbar Using Outlook 3
P Read receipts and preview panes Using Outlook 1
K Outlook 2007 preview jpg files Using Outlook 5
M How to get the preview pane handle, when it is created with menu c Outlook VBA and Custom Forms 1
E Preview of Form Region Outlook VBA and Custom Forms 4

Similar threads

Back
Top