?
Solved

How do I capture the Outlook ItemSend event from a VB.Net 2005 plug-in

Posted on 2007-12-07
4
Medium Priority
?
1,451 Views
Last Modified: 2013-11-26
I need to write a plug-in for Outlook 2003 using VB.Net 2005 that captures the ItemSend event. Using the wizard I have created the attached class but having trouble working out how to create the ItemSend event handler.

What code do I use to hook into the event? What do I need to reference so intellisense displays the events etc for the Outlook object?
imports Extensibility
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Imports Microsoft.Office.Interop.Outlook
 
<GuidAttribute("8485231B-D0A4-4A14-9FBE-52894D3CA7AF"), ProgIdAttribute("MyTestAddin.Connect")> _
Public Class Connect
	
	Implements Extensibility.IDTExtensibility2
 
    Private WithEvents applicationObject As Object
    Private addInInstance As Object
	
	Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown
	End Sub
	
	Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnAddInsUpdate
	End Sub
	
    Public Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplete
        MessageBox.Show("Addin Started")
    End Sub
	
	Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection
	End Sub
	
	Public Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
        applicationObject = application
        addInInstance = addInInst
    End Sub
 
 
 
    Public Sub ItemSend(ByVal Item As Object, ByRef Cancel As Boolean) Handles me.applicationObject.outlookevents.itemsend
        MessageBox.Show("Email Sent")
 
    End Sub
 
End Class

Open in new window

0
Comment
Question by:yoey2007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20439939
Hi,

AFAIK:

    Private WithEvents applicationObject As Object

needs to be

    Private WithEvents applicationObject As Outlook.Application


and
Public Sub ItemSend(ByVal Item As Object, ByRef Cancel As Boolean) Handles me.applicationObject.outlookevents.itemsend

should be:

 Private Sub ItemSend(ByVal Item As Object, ByRef Cancel As
Boolean) Handles applicationObject .ItemSend


hope this helps...
0
 

Author Comment

by:yoey2007
ID: 20447301
hi angelll,

What reference do I need to make in my project for the ... As Outlook.Application to work?

I currently get an error "type Outlook.Application is not defined"
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 20447485
sorry,
you need to add a reference to "Microsoft Outlook 9.0 Object Library"
Click on add Reference, select the COM tab and select "Microsoft Outlook 9.0 Object Library".
0
 

Author Comment

by:yoey2007
ID: 20455257
Thanks for your help angelll

I added a reference to "Microsoft Outlook 11.0 Object Library" as I'm using Outlook 2003 but was still getting the same error.

I changed the following line

Imports Microsoft.Office.Interop.Outlook

to

Imports Outlook = Microsoft.Office.Interop.Outlook

and it all works.


0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question