Outlook Add-In Event Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • swdesh
    New Member
    • May 2009
    • 2

    #1

    Outlook Add-In Event Problem

    Hello
    I am using VSTO 2005 SE for creating outllok add-in. I am facing a problem. My outlook events are not getting fired. I am also using System Tray Icon class for creating Icon in Task bar. If i comment the code for creating Tray Icon then it is working fine. Here is my code
    Code:
        Public Class AddIn
    
        Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
            Call initializeValue()
            Call initializeEvent()
            Call initializeTimer()
        End Sub
        
        Private Sub initializeValue()
            olApp = DirectCast(Application, Outlook.Application)
            olNS = olApp.GetNamespace("MAPI")
            olExplorer = olApp.ActiveExplorer
        End Sub
        
        Private Sub initializeEvent()
            Dim olFolder As Outlook.Folder = Nothing
            Dim olCalendarFolder As Outlook.MAPIFolder
            Dim olItems As Items
            olCalendarFolder = olNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
            olFolder = DirectCast(olCalendarFolder, Outlook.Folder)
            olItems = olCalendarFolder.Items
    
            AddHandler olItems.ItemAdd, AddressOf ApptAdded
            AddHandler olItems.ItemChange, AddressOf ApptModified
            AddHandler olItems.ItemRemove, AddressOf ApptDelete
            olFolder = Nothing
            olCalendarFolder = Nothing
        End Sub
    
        Private Sub ApptAdded(ByVal objItem As Object)
            
        End Sub
    
        Private Sub ApptModified(ByVal objItem As Object)
    
        End Sub
    
        Private Sub ApptDelete()
    
        End Sub
        
        End class
    
       Public Class  clsTrayIcon.vb
        
        Private SysTrayIcon As System.Windows.Forms.NotifyIcon
        Private AnimIconList As Icon()
        
        Public Sub New()
            InitDefaults()
        End Sub
    
        Private Sub InitDefaults()
            SysTrayIcon = New System.Windows.Forms.NotifyIcon()
            objAnimTimer = New System.Windows.Forms.Timer()
            objAnimTimer.Interval = 1
            SysTrayIcon.Text = "Test Outlook Add-in"
            AddHandler objAnimTimer.Tick, AddressOf Me.SysTrayAnimator
            Me.SysTrayIcon.Visible = True
        End Sub
        
        Public Sub SetIconRange(ByVal IconList As Object())
            AnimIconList = New Icon(IconList.Length - 1) {}
            For i As Integer = 0 To IconList.Length - 1
                AnimIconList(i) = IconList(i)
            Next
            If IconList.Length > 0 Then
                Icon = AnimIconList(0)
            End If
        End Sub
        
        Public Property Icon() As Icon
            Get
                Return Me.SysTrayIcon.Icon
            End Get
            Set(ByVal value As Icon)
                Me.SysTrayIcon.Icon = value
            End Set
        End Property
    End Class
    
    Module modGblVariable  
          Public objTrayIcon As New clsTrayIcon()
    
          Public Sub loadTrayIcon()
              Dim objValues As Object
              objValues = New Object(4) {}
              objValues(0) = My.Resources.icon1
              objValues(1) = My.Resources.icon2
              objValues(2) = My.Resources.icon3
              objValues(3) = My.Resources.icon4
              objValues(4) = My.Resources.icon5
              Call objTrayIcon.SetIconRange(objValues)
              objValues = Nothing
          End Sub
        End Module
    Please can anyone tell me why this is happing?
    Last edited by Frinavale; May 27 '09, 06:27 PM. Reason: Added code tags. Please post code in [code] [/code] tags.
Working...