> In a VSTO addin you should never use CreateObject to instantiate an
> Outlook.Application object. Instead in the Startup event do this:
>
> myOlApp = Me.Application
>
>
> Also, change your declaration of the ItemSend event handler to this:
>
> Private Sub myOlApp_ItemSend(ByVal Item As Object, _
> ByVal Cancel As Boolean) Handles myOlApp.ItemSend
>
> See if that helps.
>
> --
> Ken Slovak
> [MVP - Outlook]
>
http://www.slovaktech.com> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
>
http://www.slovaktech.com/products.htm>
>
> "sophie" <sophie[ at ]discussions.microsoft.com> wrote in message
> news:F1E82920-6941-450E-886B-2292D43859FD[ at ]microsoft.com...
> > hi,
> > I want to code a small project which can pop up a warning when user
> > click
> > send a email.
> > But it doesnt work for application_itemsend.
> > i work with VS2008, vb.
> >
> > the code is here.
> >
> > Public Class ThisAddIn
> > Public WithEvents myOlApp As Outlook.Application
> > Event ItemSend As AssemblyLoadEventHandler
> >
> >
> > Public Sub Initialize_handler()
> > myOlApp = CreateObject("Outlook.Application")
> > End Sub
> >
> >
> > Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles Me.Startup
> > Initialize_handler()
> > End Sub
> >
> > Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles Me.Shutdown
> >
> > End Sub
> >
> > Private Sub myOlAppEvents_ItemSend(ByVal Item As Object, ByVal Cancel
> > As
> > Boolean)
> > Dim prompt As String
> > prompt = "Are you sure you want to send " & Item.Subject & "?"
> > If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then
> > Cancel = True
> > End If
> >
> > End Sub
> >
> > End Class
> >
> > Any help is appreciated.
>
>