Application_ItemSend not accessed when sending email outside outlook (i.e. word or send to mail from

Status
Not open for further replies.
Outlook version
Email Account
Exchange Server 2007
I have a working piece of code in the ThisOutlookSession that traps when the user is sending an email, except if the mail is sent from Word or Excel by using the Save&Send (as attachment or pdf) option.
I can't find any hint anywhere of how to make the code work also when doing it this way.
The mail is sent, but ItemSend event isn't fired can you please provide some help?
Code
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim strSubject As String
strSubject = Item.Subject
If Len(Trim(strSubject)) = 0 Then
prompt$ = "Subject is Empty. Are you sure you want to send the Mail?"
If MsgBox(prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Subject") = vbNo Then
Cancel = True
End If
End If
End Sub
 
I'll see what i can find out - AFAIK, no, but I know just enough to be dangerous. LOL

The reason it doesn't work is because the itemsend event catches the click on the Send button, and when a program sends it message its done differently and the send event isn't triggered.
 
Ok... is outlook running? i'm told it might work if outlook is open. (It didn't work in a quick test with Outlook 2010.)

If the other program supports vba, try catching the event in that application. Add a reference to the Outlook Object library, and ensure Outlook is running, then you'd get events like you do directly in Outlook. In order to get events of the Application object, declare a variable this way:

Private WithEvents OutlookApp as Outlook.Application
 
Ok... is outlook running? i'm told it might work if outlook is open. (It didn't work in a quick test with Outlook 2010.)

If the other program supports vba, try catching the event in that application. Add a reference to the Outlook Object library, and ensure Outlook is running, then you'd get events like you do directly in Outlook. In order to get events of the Application object, declare a variable this way:

Private WithEvents OutlookApp as Outlook.Application


Hi again,
thanks for your prompt support. The outlook version I use is 2007 and the aforementioned scenario took place with outlook opened. There is no possibility to run VBA on the other program. Is there any way to capture these events from within itemSend (from ThisOutlookSession)?

Thanks in advance for your help
 
Hi can anyone help me the queries which i posted.

Regards,
Sunil
 
No, itemsend is the only event that would pick up on send. You might be able to do something with an inspector and remind the user to add a subject as soon as the message is opened, but that might be annoying if you remember most of the time.

Some of the group of developers that i asked were offline by the time I asked, so I might have some other ideas later in the day.
 
This is from Outlook developer Ken Slovak:
Calls like that from Word, Excel, etc. use Simple MAPI to open the email item. You get a new Inspector in the Inspectors collection, but no NewInspector() event to handle. In addins I use a timer to check the Inspectors collection every once in a while to see if there are any Inspectors that haven’t been put into an Inspector wrapper collection. If I find one like that I wrap it, add it to the collection and then can handle any events on the Inspector or the item (like Send).

For VBA code you’d have to use a Win32 API system timer for something like that. Personally I’d handle it with an addin though.

It's definitely more than a simple macro and I don't have any code samples for timers. :(
 
Hmmm, I see it is far more complicated than I initial thought. Thank you very much for your prompt response!!!

Anastasios
PS. If you come across with such sample of code, I'll welcome it!!! Thank you again!
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
bmtjedi Set objApp = Application Not Working in O365-32bit Using Outlook 1
avant-guvnor Outlook.Application now produces error Outlook VBA and Custom Forms 5
C Custom Application Form send Email to Another User Using Outlook 1
N Select Existing BCM Business Contact in C# application Using Outlook 0
S Using "start application" rule action Using Outlook 2
smokiibear windows security mail application not accepting username and password Using Outlook 0
Y VBA - Application Filedialog Hidden Behind Outlook Using Outlook 0
T Synchronize outlook appointments through web application. Using Outlook 1
O Outlook 2010 Stops Working When Accounting Application Tries To Send eMail Using Outlook 4
C MAPI to access a 64 bit Outlook from a 32 bit application; or access via ODBC Using Outlook 0
K Handling application.quit event Outlook VBA and Custom Forms 8
M VSTO C#: How do I declare an application scope variable? Outlook VBA and Custom Forms 2
E Turn application visibility off Outlook VBA and Custom Forms 2
T Run application from cmd button Outlook VBA and Custom Forms 5
D Outlook 2007 Will Not Send Mail From C# Application Outlook VBA and Custom Forms 7
P Supporting threads in Outlook VBA application Outlook VBA and Custom Forms 1
R vba instantiated internetExplorer.application differs from user la Outlook VBA and Custom Forms 1
K How to disconnect Application.COMAddIns.Item().Object? Outlook VBA and Custom Forms 4
D outlook.exe application error - breakpoint has been reached. fix? BCM (Business Contact Manager) 1
P Drag and Drop mails from Outlook to Clarion6 Application Outlook VBA and Custom Forms 5
J Office application does not match advisory. Why? BCM (Business Contact Manager) 3
D Application.ActiveInspector() is Null on Ribbon Load Outlook VBA and Custom Forms 1
D Application.ActiveInspector().CurrentItem Returns Wrong(Old) Value Outlook VBA and Custom Forms 3
L RE: BCM Office Application Issue BCM (Business Contact Manager) 1
R Can calendar be displayed in another Office application? Outlook VBA and Custom Forms 1
E When more than "ItemSend" is needed Using Outlook 5
B Looking for email address under ItemSend event Outlook VBA and Custom Forms 6
E Properties added to MailItem in ItemSend event visible to recipien Outlook VBA and Custom Forms 1
P ItemSend event not firing Outlook VBA and Custom Forms 2
T Hooking up the ItemSend Event... Outlook VBA and Custom Forms 1
S Outlook data file cannot be accessed message Using Outlook 5
P outlook data file casnnot be accessed Using Outlook 2
A Outlook 2010 - can't send/receive data file cannot be accessed Using Outlook 10
K The file c:\...\Outlook1.pst cannot be accessed because another workstation has modified it. Close a Using Outlook 2
M Outlook Contact Object: Is there a "last accessed" date-time prope Outlook VBA and Custom Forms 3

Similar threads

Back
Top