A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Can I capture the event ItemSend from a macro?



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 18th 08, 11:58 PM posted to microsoft.public.outlook.program_vba
Totem
external usenet poster
 
Posts: 2
Default Can I capture the event ItemSend from a macro?

Hi,

I'm trying to capture the ItemSend event from a macro (not an add-in), but
for whatever reason it's not hitting it. Even after restarting Outlook
(2007), it does not kick in. Do I have to do something special?

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
MsgBox("hi")
End Sub

or do I have to write an add-in?

Thanks

  #2  
Old April 19th 08, 12:57 AM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Can I capture the event ItemSend from a macro?

No, you don't have to write an add-in. Does other VBA code run? Have you checked the basics at http://outlookcode.com/article.aspx?id=49?

BTW, that's not a macro; it's an event handler.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Totem" wrote in message ...
Hi,

I'm trying to capture the ItemSend event from a macro (not an add-in), but
for whatever reason it's not hitting it. Even after restarting Outlook
(2007), it does not kick in. Do I have to do something special?

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
MsgBox("hi")
End Sub

or do I have to write an add-in?

Thanks

  #3  
Old April 19th 08, 01:13 AM posted to microsoft.public.outlook.program_vba
Totem
external usenet poster
 
Posts: 2
Default Can I capture the event ItemSend from a macro?

I didn't have it under "ThisOutlookSession", so I've placed the code there
and it works now. Is this the only way? there's no way to have it in a
module so that I can easily share it with co-workers?
I'd like to know what's the easiest that I can share it with others and have
them update it as I provide them with a new version.

thanks

"Sue Mosher [MVP-Outlook]" wrote:

No, you don't have to write an add-in. Does other VBA code run? Have you checked the basics at http://outlookcode.com/article.aspx?id=49?

BTW, that's not a macro; it's an event handler.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Totem" wrote in message ...
Hi,

I'm trying to capture the ItemSend event from a macro (not an add-in), but
for whatever reason it's not hitting it. Even after restarting Outlook
(2007), it does not kick in. Do I have to do something special?

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
MsgBox("hi")
End Sub

or do I have to write an add-in?

Thanks


  #4  
Old April 19th 08, 03:56 AM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Can I capture the event ItemSend from a macro?

If you want something to share with co-workers, that should be an add-in. There is no supported method for distributing VBA code; see http://www.outlookcode.com/article.aspx?id=28

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Totem" wrote in message ...
I didn't have it under "ThisOutlookSession", so I've placed the code there
and it works now. Is this the only way? there's no way to have it in a
module so that I can easily share it with co-workers?
I'd like to know what's the easiest that I can share it with others and have
them update it as I provide them with a new version.

thanks

"Sue Mosher [MVP-Outlook]" wrote:

No, you don't have to write an add-in. Does other VBA code run? Have you checked the basics at http://outlookcode.com/article.aspx?id=49?

BTW, that's not a macro; it's an event handler.



"Totem" wrote in message ...
Hi,

I'm trying to capture the ItemSend event from a macro (not an add-in), but
for whatever reason it's not hitting it. Even after restarting Outlook
(2007), it does not kick in. Do I have to do something special?

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
MsgBox("hi")
End Sub

or do I have to write an add-in?


  #5  
Old April 22nd 08, 05:02 PM posted to microsoft.public.outlook.program_vba
Mike YO_BEE B
external usenet poster
 
Posts: 7
Default Can I capture the event ItemSend from a macro?

Here is my code. I am a newbie at coding, but I found this and it works, but
I am not sure how to have this code start up automaticlly upon the start up
of OUTLOOK

Public WithEvents myOlApp As Outlook.Application

Public Sub Initialize_handler()
Set myOlApp = CreateObject("Outlook.Application")
End Sub

Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim prompt As String
prompt = "Are you sure you want to send " & "?"
If MsgBox(prompt, 4 + 16, "This is a Warning!") = vbNo Then
Cancel = True
End If

End Sub


"Totem" wrote:

Hi,

I'm trying to capture the ItemSend event from a macro (not an add-in), but
for whatever reason it's not hitting it. Even after restarting Outlook
(2007), it does not kick in. Do I have to do something special?

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
MsgBox("hi")
End Sub

or do I have to write an add-in?

Thanks

  #6  
Old April 23rd 08, 03:29 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Can I capture the event ItemSend from a macro?

Put that code in the ThisOutlookSession class module. You don't need to
declare an Application object WithEvents in that class BTW. Then in the
Application_Startup event handler call your initialization.

--
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


"Mike "YO_BEE" B" wrote in message
...
Here is my code. I am a newbie at coding, but I found this and it works,
but
I am not sure how to have this code start up automaticlly upon the start
up
of OUTLOOK

Public WithEvents myOlApp As Outlook.Application

Public Sub Initialize_handler()
Set myOlApp = CreateObject("Outlook.Application")
End Sub

Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim prompt As String
prompt = "Are you sure you want to send " & "?"
If MsgBox(prompt, 4 + 16, "This is a Warning!") = vbNo Then
Cancel = True
End If

End Sub


"Totem" wrote:

Hi,

I'm trying to capture the ItemSend event from a macro (not an add-in),
but
for whatever reason it's not hitting it. Even after restarting Outlook
(2007), it does not kick in. Do I have to do something special?

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
MsgBox("hi")
End Sub

or do I have to write an add-in?

Thanks


  #7  
Old April 23rd 08, 03:42 PM posted to microsoft.public.outlook.program_vba
Mike YO_BEE B
external usenet poster
 
Posts: 7
Default Can I capture the event ItemSend from a macro?

would it be something like this under the Class Modules ?

Public Sub Startup()
Set myOlApp = CreateObject("Outlook.Application")
End Sub

Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim prompt As String
prompt = "Are you sure you want to send " & "?"
If MsgBox(prompt, 4 + 16, "This is a Warning!") = vbNo Then
Cancel = True
End If

End Sub


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

Put that code in the ThisOutlookSession class module. You don't need to
declare an Application object WithEvents in that class BTW. Then in the
Application_Startup event handler call your initialization.

--
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


"Mike "YO_BEE" B" wrote in message
...
Here is my code. I am a newbie at coding, but I found this and it works,
but
I am not sure how to have this code start up automaticlly upon the start
up
of OUTLOOK

Public WithEvents myOlApp As Outlook.Application

Public Sub Initialize_handler()
Set myOlApp = CreateObject("Outlook.Application")
End Sub

Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim prompt As String
prompt = "Are you sure you want to send " & "?"
If MsgBox(prompt, 4 + 16, "This is a Warning!") = vbNo Then
Cancel = True
End If

End Sub


"Totem" wrote:

Hi,

I'm trying to capture the ItemSend event from a macro (not an add-in),
but
for whatever reason it's not hitting it. Even after restarting Outlook
(2007), it does not kick in. Do I have to do something special?

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
MsgBox("hi")
End Sub

or do I have to write an add-in?

Thanks



  #8  
Old April 23rd 08, 04:31 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Can I capture the event ItemSend from a macro?

No. It would be in the ThisOutlookSessionClass, you would never create an
Outlook.Application object (you use the intrinsic Application object) and
you use Application_Startup, as I said before.

--
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


"Mike "YO_BEE" B" wrote in message
...
would it be something like this under the Class Modules ?

Public Sub Startup()
Set myOlApp = CreateObject("Outlook.Application")
End Sub

Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim prompt As String
prompt = "Are you sure you want to send " & "?"
If MsgBox(prompt, 4 + 16, "This is a Warning!") = vbNo Then
Cancel = True
End If

End Sub


  #9  
Old April 23rd 08, 05:48 PM posted to microsoft.public.outlook.program_vba
Mike YO_BEE B
external usenet poster
 
Posts: 7
Default Can I capture the event ItemSend from a macro?

So do I play my code inside the Application_startup() like this

Public Sub Application_startup()

Private Sub msg_ItemSend(ByVal Item As Object, Cancel As Balloon)
Dim Prompt As String
Prompt = "Are you sure you want to send " & msg.To & " ?"
If MsgBox(Prompt, vbYesNo + vbInformation, "WARNING!!!!! You are
sending to a Distibustion Group") = vbNo Then
Cancel = True
End If
End Sub

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

No. It would be in the ThisOutlookSessionClass, you would never create an
Outlook.Application object (you use the intrinsic Application object) and
you use Application_Startup, as I said before.

--
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


"Mike "YO_BEE" B" wrote in message
...
would it be something like this under the Class Modules ?

Public Sub Startup()
Set myOlApp = CreateObject("Outlook.Application")
End Sub

Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim prompt As String
prompt = "Are you sure you want to send " & "?"
If MsgBox(prompt, 4 + 16, "This is a Warning!") = vbNo Then
Cancel = True
End If

End Sub



  #10  
Old April 23rd 08, 11:06 PM posted to microsoft.public.outlook.program_vba
Mike YO_BEE B
external usenet poster
 
Posts: 7
Default Can I capture the event ItemSend from a macro?

I was able to get the VBA Send Capture to work, but now I want to add some
filtering
Here is my copy for filtering one address, but I want to filter Multiple
addresses


Private Sub Application_Startup()

End Sub



Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim prompt As String

If Item.To = "TestDistList" Then

prompt = "Are you sure you want to send " & Item.To & "?"
If MsgBox(prompt, vbYesNo + vbExclamation, "Sample") = vbNo Then
Cancel = True
End If
Else
End If
End Sub







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

No. It would be in the ThisOutlookSessionClass, you would never create an
Outlook.Application object (you use the intrinsic Application object) and
you use Application_Startup, as I said before.

--
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


"Mike "YO_BEE" B" wrote in message
...
would it be something like this under the Class Modules ?

Public Sub Startup()
Set myOlApp = CreateObject("Outlook.Application")
End Sub

Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim prompt As String
prompt = "Are you sure you want to send " & "?"
If MsgBox(prompt, 4 + 16, "This is a Warning!") = vbNo Then
Cancel = True
End If

End Sub



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ItemSend Event Catalin Outlook and VBA 4 January 17th 08 08:17 PM
Capture Outlook 2007 Item Send Event apondu Add-ins for Outlook 0 December 11th 07 08:45 AM
Cancelling and closing a mailitem in itemsend event bstrum Add-ins for Outlook 1 June 19th 07 06:53 AM
Write RTF-Body on ItemSend event Thomas Add-ins for Outlook 2 February 12th 07 12:22 PM
ItemSend event differences betweek W2K & WXP Lionel H Outlook and VBA 4 October 20th 06 04:16 PM


All times are GMT +1. The time now is 10:19 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.