By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,247 Members | 1,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,247 IT Pros & Developers. It's quick & easy.

Outlook Add-In Event Problem

P: 2
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
Expand|Select|Wrap|Line Numbers
  1.     Public Class AddIn
  2.  
  3.     Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
  4.         Call initializeValue()
  5.         Call initializeEvent()
  6.         Call initializeTimer()
  7.     End Sub
  8.  
  9.     Private Sub initializeValue()
  10.         olApp = DirectCast(Application, Outlook.Application)
  11.         olNS = olApp.GetNamespace("MAPI")
  12.         olExplorer = olApp.ActiveExplorer
  13.     End Sub
  14.  
  15.     Private Sub initializeEvent()
  16.         Dim olFolder As Outlook.Folder = Nothing
  17.         Dim olCalendarFolder As Outlook.MAPIFolder
  18.         Dim olItems As Items
  19.         olCalendarFolder = olNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
  20.         olFolder = DirectCast(olCalendarFolder, Outlook.Folder)
  21.         olItems = olCalendarFolder.Items
  22.  
  23.         AddHandler olItems.ItemAdd, AddressOf ApptAdded
  24.         AddHandler olItems.ItemChange, AddressOf ApptModified
  25.         AddHandler olItems.ItemRemove, AddressOf ApptDelete
  26.         olFolder = Nothing
  27.         olCalendarFolder = Nothing
  28.     End Sub
  29.  
  30.     Private Sub ApptAdded(ByVal objItem As Object)
  31.  
  32.     End Sub
  33.  
  34.     Private Sub ApptModified(ByVal objItem As Object)
  35.  
  36.     End Sub
  37.  
  38.     Private Sub ApptDelete()
  39.  
  40.     End Sub
  41.  
  42.     End class
  43.  
  44.    Public Class  clsTrayIcon.vb
  45.  
  46.     Private SysTrayIcon As System.Windows.Forms.NotifyIcon
  47.     Private AnimIconList As Icon()
  48.  
  49.     Public Sub New()
  50.         InitDefaults()
  51.     End Sub
  52.  
  53.     Private Sub InitDefaults()
  54.         SysTrayIcon = New System.Windows.Forms.NotifyIcon()
  55.         objAnimTimer = New System.Windows.Forms.Timer()
  56.         objAnimTimer.Interval = 1
  57.         SysTrayIcon.Text = "Test Outlook Add-in"
  58.         AddHandler objAnimTimer.Tick, AddressOf Me.SysTrayAnimator
  59.         Me.SysTrayIcon.Visible = True
  60.     End Sub
  61.  
  62.     Public Sub SetIconRange(ByVal IconList As Object())
  63.         AnimIconList = New Icon(IconList.Length - 1) {}
  64.         For i As Integer = 0 To IconList.Length - 1
  65.             AnimIconList(i) = IconList(i)
  66.         Next
  67.         If IconList.Length > 0 Then
  68.             Icon = AnimIconList(0)
  69.         End If
  70.     End Sub
  71.  
  72.     Public Property Icon() As Icon
  73.         Get
  74.             Return Me.SysTrayIcon.Icon
  75.         End Get
  76.         Set(ByVal value As Icon)
  77.             Me.SysTrayIcon.Icon = value
  78.         End Set
  79.     End Property
  80. End Class
  81.  
  82. Module modGblVariable  
  83.       Public objTrayIcon As New clsTrayIcon()
  84.  
  85.       Public Sub loadTrayIcon()
  86.           Dim objValues As Object
  87.           objValues = New Object(4) {}
  88.           objValues(0) = My.Resources.icon1
  89.           objValues(1) = My.Resources.icon2
  90.           objValues(2) = My.Resources.icon3
  91.           objValues(3) = My.Resources.icon4
  92.           objValues(4) = My.Resources.icon5
  93.           Call objTrayIcon.SetIconRange(objValues)
  94.           objValues = Nothing
  95.       End Sub
  96.     End Module
Please can anyone tell me why this is happing?
May 26 '09 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.