vb.Net Outlook Event Examples

Add-in Express™ Support Service
That's what is more important than anything else

vb.Net Outlook Event Examples
 
Bill Philbin




Posts: 2
Joined: 2005-04-24
Looking for an example to help with a project to convert vb6/vba code to vb.Net. Specifically, I'm converting an application that monitors item change events on outlook item collections.

Sample code is appreciated.

Posted 24 Apr, 2005 17:30:12 Top
Eugene Starostin


Guest


Hello Bill,

As I see there is no a sample with item change event but in this forum you can find some examples for VB.NET and Outlook.

Also we have developed several sample add-ins that show how to handle Outlook events in VB.NET. They are http://www.add-in-express.com/free-addins/net-outlook-addin.php and http://www.add-in-express.com/support/addin-vb-net.php.
Posted 25 Apr, 2005 04:15:14 Top
Bill Philbin




Posts: 2
Joined: 2005-04-24
Thanks. Looked at the examples but it's not what I'm looking for. I suspect the problem is potentially with tne interop assemblies. The problem is that they may not include all the methods/properties of the base COM object.

In VB I could:

' Dim a variable withevents
Public WithEvents colItems As Outlook.Items

' Set the variable to a collection change event (e.g. itemadd)
Set colItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items

'create a procedure that would fire when the event was triggered.
Private Sub ColItems_ItemAdd(ByVal item As Object)

When I attempt to do the same in vb.net I get "no such interface" regardless of whether i use withevents or addhandler.

As Add-in express doesn't seem to support events on items (I could use the new mail event but want to monitor task items as well), I'm wondering if you have any idea on how to do.

Bill


Posted 25 Apr, 2005 19:49:24 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Bill.

You do everything correct. The point is that the Interop.Outlook.dll that is created via Visual Studio contains some bugs.
To solve this issue you should use PIAs from Microsoft. You can download PIAs here: http://www.microsoft.com/downloads/details.aspx?FamilyId=C41BD61E-3060-4F71-A6B4-01FEBA508E52&displaylang=en
There is one more way to connect to the items events in Outlook. You can use the UCOMIConnectionPoint class to establish a connection between the connection point of Outlook.ItemsEvents object and the caller's sink object. We have an example how it can be done. Please download here:
http://www.add-in-express.com/projects/olitemsexample.zip
Posted 26 Apr, 2005 03:56:50 Top