A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Addhandler not working



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 24th 07, 03:56 PM posted to microsoft.public.outlook.program_vba
Dhananjay
external usenet poster
 
Posts: 33
Default Addhandler not working

Hi all,
I have created one COM-addin in VSTO SE / VB 2005 / Outlook 2003.
Same code works fine when I created the addin for outlook 2007.

My code snippet is as follows

' In general section
Private WithEvents myContact As ContactItem
Private ItemsCollection As Generic.IList(Of Inspector)
Private WithEvents myInspectors As Inspectors

' This is NewInspctors event
Private Sub myInspectors_NewInspector(ByVal Inspector As
Microsoft.Office.Interop.Outlook.Inspector) Handles
myInspectors.NewInspector
AddTrace("Opening New Insp Start")
If ItemsCollection Is Nothing Then
AddTrace("Creating inspectors collection")
ItemsCollection = New Generic.List(Of Inspector)
End If
If
Inspector.CurrentItem.MessageClass.ToUpper.Contain s("IPM.CONTACT")
Then
AddTrace("Contact inspector found")
ItemsCollection.Add(Inspector)
AddTrace("Adding handlers")
AddHandler
ItemsCollection(ItemsCollection.IndexOf(Inspector) ).Activate,
AddressOf GenericActiveInspector
AddHandler
ItemsCollection(ItemsCollection.IndexOf(Inspector) ).Close, AddressOf
GenericCloseInspector
AddTrace("Setting inspectors")
GenericInsp = Inspector
End If
AddTrace("Opening New Insp End")
End Sub

' This is one addhandler
Sub GenericActiveInspector()
AddTrace("Checking active inspector Start")
If Application.ActiveInspector IsNot Nothing Then
GenericInsp = Application.ActiveInspector
End If
Try
If TypeName(GenericInsp.CurrentItem).ToUpper =
"CONTACTITEM" Then
AddTrace("Contact inspector found")
myContact = TryCast(GenericInsp.CurrentItem,
ContactItem)
If myContact IsNot Nothing Then
'MsgBox("contact")
AddTrace("Contact set - Success")
Else
AddTrace("Contact set - Unsuccess")
End If
End If
Catch ex As System.Exception
AddTrace(ex.Message)
End Try
AddTrace("Checking active inspector End")
End Sub

'This is my another handler
Sub GenericCloseInspector()
AddTrace("Closing active inspector Start")
Try
If
TypeName(Application.ActiveInspector.CurrentItem). ToUpper =
"CONTACTITEM" Then
AddTrace("Contact inspector found")
If Application.ActiveInspector Is Nothing Then
AddTrace("ActiveInsp is not Nothing")
RemoveHandler
ItemsCollection(ItemsCollection.IndexOf(Applicatio n.ActiveInspector)).Close,
AddressOf GenericCloseInspector
AddTrace("Removed close")
RemoveHandler
ItemsCollection(ItemsCollection.IndexOf(Applicatio n.ActiveInspector)).Activate,
AddressOf GenericActiveInspector
AddTrace("Removed activeinsp")

ItemsCollection.RemoveAt(ItemsCollection.IndexOf(A pplication.ActiveInspector))
myContact = Nothing
Else
AddTrace("ActiveInsp Nothing")
End If
AddTrace("Removed item from collection")
End If
Catch ex As System.Exception
AddTrace("Exception while closing inspector - " &
ex.Message)
MsgBox("Exception while closing inspector - " &
ex.Message, MsgBoxStyle.Critical Or MsgBoxStyle.SystemModal)
End Try
AddTrace("Closing active inspector End ")
End Sub

Now whenever I open any contactitem, I add it to the collection &
whenever I activate any contactitem's inspector, while debugging
control goes to "GenericActiveInspector" method, I set myContact there
& proceed my writing through it.
But whenever I close any contactitem's inspector, my
"GenericCloseInspector" method isn't fired.
So what is the problem for outlook 2003 version.

Thanks in advance,
Dhananjay
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
AddHandler is not working Dhananjay Outlook and VBA 1 October 13th 07 09:05 PM
Add-Ins not working Terri Add-ins for Outlook 0 June 19th 07 01:28 PM
just to see if this is working Michael Santovec Outlook Express 2 June 17th 07 06:04 PM
OE url not working Henry Kolesnik Outlook Express 1 December 3rd 06 04:23 PM
Is this working now? Oldfield-Cherry Outlook Express 1 June 12th 06 08:37 PM


All times are GMT +1. The time now is 07:04 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.