Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: application item send

Geek News

application item send
sophie 11/10/2008 1:38:00 AM
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.
RE: application item send
sophie 11/10/2008 2:44:04 AM
i cannot capture itemsend event. I can capture the event in visual Basic 6.0
in the same way. but i cant get it here in vb studio 2008. I dont know why.

"sophie" wrote:

[Quoted Text]
> 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.
Re: application item send
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 11/10/2008 2:26:14 PM
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...
[Quoted Text]
> 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.

Re: application item send
sophie 11/11/2008 2:27:00 AM
Thanks for your help, Ken.
I have worked out.
BTW, Private Sub myOlApp_ItemSend(ByVal Item As Object, _
ByVal Cancel As Boolean) Handles myOlApp.ItemSend
should be (ByVal Item As Object, ByRef Cancel As Boolean)

"Ken Slovak - [MVP - Outlook]" wrote:

[Quoted Text]
> 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.
>
>
Re: application item send
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 11/11/2008 2:18:17 PM
So it should be, thanks for the correction. I just copied your original
event signature and didn't bother to actually study it closely.

--
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:1B2D5136-C195-4ED0-8E10-99A419E267FA[ at ]microsoft.com...
[Quoted Text]
> Thanks for your help, Ken.
> I have worked out.
> BTW, Private Sub myOlApp_ItemSend(ByVal Item As Object, _
> ByVal Cancel As Boolean) Handles myOlApp.ItemSend
> should be (ByVal Item As Object, ByRef Cancel As Boolean)

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net