Solved

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

Posted on 2007-12-07
4
1,422 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
  • 2
  • 2
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
Comment Utility
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 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now