item_send event

Status
Not open for further replies.
G

Gilles LEBRET

Hi,

There is a little problem with Item_send event in OL2003.

Supose you have this code in your vba project :

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

msgbox "Hello"

end sub

You are expected to see "ok" every time you send a email. This code runs

fine when you compose a new mail directly with outlook.

Now, send a file via "Send to -> recipient" : open explorer file. With the

mouse, right-clic on a file and select : "Send to -> recipient"

A new message appears with you file attached. But If you send it, you do not

see "Hello" : Application_ItemSend event is not fired , even if Outlook

is running or not.

This problem do not occurs if a ComAddin is attached to Outlook : the

ComAddin is able to catch

Application_ItemSend when file is sent from explorer (even if Outlook is

running or not).

We would like to understand why a difference exists between VBA and Comaddin

> .

Is there any workaround to force VBA to catch event when file is sent from

explorer ?

Thanks

Gilles Lebret
 
K

Ken Slovak - [MVP - Outlook]

Send To uses Simple MAPI to open or send Outlook items. The Inspectors

opened as a result of a Simple MAPI command do not fire the NewInspector()

event, and are opened modally. They do add an Inspector to the Inspectors

collection, but there is no event that fires when the Simple MAPI Inspector

opens.

The way I usually handle this is to use a timer to check for Inspectors that

aren't already being handled by NewInspector(). That requires flags to

interlock handling so you don't handle an item twice or miss one, plus you'd

need wrapper classes that declared MailItems WithEvents so you can handle

their Send() events. I add each wrapper class to a collection to keep it

alive, updating the collection for each new Inspector and for each one that

closes.

I do however handle all this using addins. VBA code is just for prototyping

in Outlook or personal macros, it's not good for deploying or distributing

code.

"Gilles LEBRET" <glebret@a2.socetem.fr> wrote in message

news:%23W1gfvJ$KHA.1700@TK2MSFTNGP02.phx.gbl...
> Hi,
> There is a little problem with Item_send event in OL2003.

> Supose you have this code in your vba project :

> Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
> msgbox "Hello"
> end sub

> You are expected to see "ok" every time you send a email. This code runs
> fine when you compose a new mail directly with outlook.

> Now, send a file via "Send to -> recipient" : open explorer file. With the
> mouse, right-clic on a file and select : "Send to -> recipient"
> A new message appears with you file attached. But If you send it, you do
> not see "Hello" : Application_ItemSend event is not fired , even if
> Outlook
> is running or not.

> This problem do not occurs if a ComAddin is attached to Outlook : the
> ComAddin is able to catch
> Application_ItemSend when file is sent from explorer (even if Outlook is
> running or not).

> We would like to understand why a difference exists between VBA and
> Comaddin .
> Is there any workaround to force VBA to catch event when file is sent from
> explorer ?

> Thanks

> Gilles Lebret

>
 
Y

yves pion

Hello,

thanks for your answer.

one question about your sample code (wrapper class ) :

Where must I put this code ?

If it is in ComAddin, this won't help me because I already know that my

ComAddin catch event when using SendTO.

Could I put this wrapper class into outlook VBA ?

Thanks.
<kenslovak@mvps.org> a écrit dans le message

de news: %23mxgJdN$KHA.1892@TK2MSFTNGP05.phx.gbl...
> Send To uses Simple MAPI to open or send Outlook items. The Inspectors
> opened as a result of a Simple MAPI command do not fire the NewInspector()
> event, and are opened modally. They do add an Inspector to the Inspectors
> collection, but there is no event that fires when the Simple MAPI
> Inspector opens.

> The way I usually handle this is to use a timer to check for Inspectors
> that aren't already being handled by NewInspector(). That requires flags
> to interlock handling so you don't handle an item twice or miss one, plus
> you'd need wrapper classes that declared MailItems WithEvents so you can
> handle their Send() events. I add each wrapper class to a collection to
> keep it alive, updating the collection for each new Inspector and for each
> one that closes.

> I do however handle all this using addins. VBA code is just for
> prototyping in Outlook or personal macros, it's not good for deploying or
> distributing code.

> >

>

> "Gilles LEBRET" <glebret@a2.socetem.fr> wrote in message
> news:%23W1gfvJ$KHA.1700@TK2MSFTNGP02.phx.gbl...
> > Hi,
> > There is a little problem with Item_send event in OL2003.
>

>> Supose you have this code in your vba project :
>

>> Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
> > msgbox "Hello"
> > end sub
>

>> You are expected to see "ok" every time you send a email. This code runs
> > fine when you compose a new mail directly with outlook.
>

>> Now, send a file via "Send to -> recipient" : open explorer file. With
> > the mouse, right-clic on a file and select : "Send to -> recipient"
> > A new message appears with you file attached. But If you send it, you do
> > not see "Hello" : Application_ItemSend event is not fired , even if
> > Outlook
> > is running or not.
>

>
>> This problem do not occurs if a ComAddin is attached to Outlook : the
> > ComAddin is able to catch
> > Application_ItemSend when file is sent from explorer (even if Outlook is
> > running or not).
>

>> We would like to understand why a difference exists between VBA and
> > Comaddin .
> > Is there any workaround to force VBA to catch event when file is sent
> > from explorer ?
>

>> Thanks
>

>> Gilles Lebret
>

>
>>

>
 
K

Ken Slovak - [MVP - Outlook]

You can create wrapper classes in VBA just as you can in VB or C#. You can

add instances of the classes to a collection in VBA to keep them alive. Just

create a new class and add your WithEvents declarations to the class so it

can handle events for the Inspector and item.

The main problem is using timers in VBA code. You'd need to use VB-type code

to create and handle a Win32 system timer. There are examples of that for

VB6 at www.vbaccelerator.com, which can be adapted to VBA code.

"yves pion" <hotline@socetem.fr> wrote in message

news:utUq%23AX$KHA.4308@TK2MSFTNGP04.phx.gbl...
> Hello,
> thanks for your answer.

> one question about your sample code (wrapper class ) :

> Where must I put this code ?

> If it is in ComAddin, this won't help me because I already know that my
> ComAddin catch event when using SendTO.
> Could I put this wrapper class into outlook VBA ?
> Thanks.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
A Unflag Inbox and Flag Inbox with Orange Category After Item is send Outlook VBA and Custom Forms 3
Z Item.Recipients for Task Assignment on Send Outlook VBA and Custom Forms 10
N Saving .msg as sent item on send Outlook VBA and Custom Forms 1
D item send not tigering. Using Outlook 5
G Outlook 2007 Meeting Item Send Button Outlook VBA and Custom Forms 10
P Move mail item after send Outlook VBA and Custom Forms 2
O In Agenda-view - How to copy an existing item months ahead or back? Using Outlook 0
S Outlook 2016 dont delete inbox item Using Outlook 0
talla Can't open Outlook Item. Using Outlook 0
N Item cannot be saved because it was modified by another user or window, and, Item could not be moved... Using Outlook 0
B Zoom automatically next email item (VBA) Outlook VBA and Custom Forms 2
S Command Button_Click action on Item/Reminder Outlook VBA and Custom Forms 3
A Run-time error '430' on certain emails when trying to set "Outlook.mailitem" as "ActiveExplorer.Selection.Item" Outlook VBA and Custom Forms 2
C Copy Move item won't work Outlook VBA and Custom Forms 2
T Pictures degrade each time an Outlook item is edited and re-saved Using Outlook 1
B Change row background color of selected item Using Outlook 1
P Outlook 2013 "Item could not be moved - still an issue for Outlook 2013 Using Outlook 0
R Error when trying to forward current email item Outlook VBA and Custom Forms 7
geoffnoakes Find Contacts with UDFs "in this item" Using Outlook 1
T "cannot find the calendar folder for this item" - calendar items stuck in outbox Using Outlook 0
GregS Many Sent Item folders Using Outlook 3
B Select / activate first email item in the searched query Using Outlook 1
4 Macro to set the category of Deleted Item? Outlook VBA and Custom Forms 2
N "Discussion" item Using Outlook 3
T outlook.com opens with "item not found" Using Outlook 1
Peter H Williams How to Move Mail item after processing Outlook VBA and Custom Forms 5
C Change default "Save Sent Item To" folder Outlook VBA and Custom Forms 9
M Shortcut to another outlook item Using Outlook 0
M Item edits doesn't always sync Using Outlook 11
Cdub27 Your changes to this item couldn't be saved because Server Denied Operation (HTTP 403 Forbidden) Using Outlook 1
M VBA to change flag status in outlook contact item Outlook VBA and Custom Forms 3
P Replying to calendar item using VBA Outlook VBA and Custom Forms 4
G Outlook item link Using Outlook 0
Q VBA Script to move item in secondary mailbox Outlook VBA and Custom Forms 2
D Save Sent Item to Using Outlook 0
T outlook 2010 mail item count doesnt match display Outlook VBA and Custom Forms 3
Jeanne Goodman Delete Calendar Item Bypassing Deleted Items folder Outlook VBA and Custom Forms 2
Diane Poremsky Display the Created Date field of any Outlook item Using Outlook 0
Diane Poremsky Outlook VBA: Work with Open Item or Selected Item Using Outlook 0
M How does Outlook determine item numbers in a folder? Outlook VBA and Custom Forms 3
J "This item has been changed still want to delete it" message Using Outlook 3
oliv- HIDE ITEM Outlook VBA and Custom Forms 3
D help with Item/Inspector close event Outlook VBA and Custom Forms 1
T Create new item in public folder using VBscript Outlook VBA and Custom Forms 1
D Shared Mailbox with mail item marked as "private" Using Outlook 0
Diane Poremsky Change Item Count on All Folders in a Data File Using Outlook 0
M Recurring icon for custom form task item Outlook VBA and Custom Forms 6
williamlambton Reinstate "Open" button on mail item right-click context menu. Outlook Wishlist 2
N Adding Appointment Item in Outlook to Shared Calendar Folder Outlook VBA and Custom Forms 7
V Locate item Account Outlook VBA and Custom Forms 7

Similar threads

Top