MailItem_Open event wont fire on some machines

J

johan

I have a VB6 COM addin that runs in Outlook 2003. It works perfect on
some machines, but the MailItem_Open event wont fire on other machines.

The addin show check when the user creates a new email and instead of
showing an empty email a dialogbox should appear where the user can
choose a mail template. Everything works just fine, on must machines.

The following events works everywhere:
AddinInstance_OnConnection
oInspectors_NewInspector
oInspector_Activate

But the oMail_Open event dont fire on some machines. All machines have
Office 2003 SP2.

Here is the code:

Option Explicit

Private WithEvents oApp As Outlook.Application
Private WithEvents oInspectors As Outlook.Inspectors
Private WithEvents oInspector As Outlook.Inspector
Private WithEvents oMail As Outlook.MailItem

Private Sub AddinInstance_OnConnection(ByVal Application As Object,
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal
AddInInst As Object, custom() As Variant)
Globals.ManualMode = False
Set oApp = Application
Set oInspectors = oApp.Inspectors
End Sub

Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As
AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
Set oMail = Nothing
Set oInspector = Nothing
Set oInspectors = Nothing
Set oApp = Nothing
End Sub

Private Sub oInspector_Activate()
If TypeName(oInspector.CurrentItem) = "MailItem" Then
Set oMail = oInspector.CurrentItem
Else
Set oMail = Nothing
End If
End Sub

Private Sub oInspectors_NewInspector(ByVal Inspector As Inspector)
Set oInspector = Inspector
End Sub

Private Sub oMail_Open(Cancel As Boolean)
MsgBox "Will it fire?"

If oMail.EntryID <> "" Or oMail.ConversationIndex <> "" Then
Exit Sub
End If

If Not Globals.ManualMode Then
Cancel = True
Load frmTemplates
frmTemplates.Show
End If
Globals.ManualMode = False
End Sub



Please help!

// Johan
 
K

Ken Slovak - [MVP - Outlook]

So, what's different on those machines where it doesn't work? Are they
possibly using synch to PDA software or something like that which opens
Outlook with no UI when started?
 
J

johan

With a little more testing it seems like it's the account that differ.
I have no idea what's the different. Both accounts are administrators
on the local machine. With one account it works, with another it
doesn't. This is on the same machine. It's two different Outlook
accounts as well.

This is really strange!
 
J

johan

Now it's even more strange. Using Account 1 on Machine 1 dont work.
Using Account 2 on Machine 1 work. Using Account 1 on Machine 2 work.
using Account 2 on Machine 2 work.

I dont get it. What's wrong?
 
K

Ken Slovak - [MVP - Outlook]

I have no idea. When you say "account" do you mean Outlook profile, email
account or Windows logon?

If it's Windows logon then maybe the addin isn't registered in the HKCU hive
of the registry for that logon.
 
J

johan

I meant Windows Account, but it might be the Outlook profile.

I did a workaround that hade a seperate button to open my dialogbox,
instead of canceling the Mail_Open event. Not as pretty, but it
works...

// Johan
 
B

~BizCoach~

I have ran into this problem before. The problem is most likely to be with
the Windows Profile of the user, and specifically the problem lies within the
UsrClass.dat file that stores the User-Classes hive of the Windows registry
for that user on that machine.

Renaming the UsrClass.dat file for this user on the problem machine may
solve the problem.

DETAILS ---

Since Windows will re-generate the UsrClass.dat file when a given user logs
into Windows, login as Account2 and locate the UsrClass.dat file within the
Windows Profile directory for Account1. It is a hidden, system file that
cannot be deleted while the user who owns that Windows Profile is currently
logged in and using it.

When you locate the UsrClass.dat file in the Windows Profile folders for the
problem user, just rename the file to UsrClass.sav or something. This way if
the fix does not work for you it is a simple matter to delete the new
UsrClass.dat file that will be created and revert back to the original one by
deleting the new one and then renaming the original one back.

After you rename the file, logout as Account2 and then login as Account1 and
test the result. I believe you will find that this solves the problem
without having to destroy or rebuild the Outlook Profile, the Windows Profile
or the machine.

The key to this particular issue is the fact that two different user logins
having the same rights do not both work on this machine yet the user login
having the problem on this machine works on another machine.

Therefore, the problem is specific to that user's profile on that specific
machine, and that points to the UsrClass.dat file or possibly to the Outlook
Profile for the user on that machine. I have seen the Outlook Profile cause
problems if Cached Exchange Mode / Offline Folders are enabled on more than
one machine for a given user, but in most cases I've come across it is a
problem with the UsrClass.dat file.

Please post back whether or not this does the trick for you.

~BizCoach~
 

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