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

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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
 
Outlook version
Outlook 2007
Email Account
Exchange Server 2007
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
 

sunil

New Member
Outlook version
Outlook 2010 32 bit
Email Account
Hi can anyone help me the queries which i posted.

Regards,
Sunil
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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. :(
 
Outlook version
Outlook 2007
Email Account
Exchange Server 2007
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.
Thread starter Similar threads Forum Replies Date
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
J Delays when changing from one application to another in Outlook Using Outlook 2
T How can I send e-mail from an Access 2010 application using Outlook not CDO Using Outlook 1
P All of a sudden I cannot open the INBOX file. It asks me to close any application and restart. Done that several times. Nothing Using Outlook 1
M Determine if a public Folder is used by an Application Using Outlook 2
U How do I copy my address book in a vcard application? Using Outlook 1
M Server Error in '/FacilityService' Application. Exchange Server Administration 3
B Identify SMTP email submitted from IP or Application for rule creation? Exchange Server Administration 7
S incompatible application cannot open hyperlinks in email messages__ Using Outlook 2
B OUTLOOK 2010 Set up wrong and now can't open application to fix it... Using Outlook 1
H Importing Unread emails to a 3rd party Application - Civica Using Outlook 1
K Outlook 2007 - error opening the application Using Outlook 1
B Microsoft Visual C++ Runtime Library message, "This application has requested the Runtime to termina Using Outlook 1
A Access 64 bit Outlook 2010 from 32 bit C++ application Using Outlook 1
N Business Application for Master Category List in 2010 Outlook's Business Contact Manager Using Outlook 1
D An error in the transmission of the command to the application Using Outlook 1
U Outlook 2003- Incompatible Application - Using Outlook 1
S Error 'outlook cannot launch an application to handle d:\xxxxxx' when try to insert file. Using Outlook 1
R New Relay for an application server to send bulk mail Exchange Server Administration 2
T Use edge servers as relay machines for application servers Exchange Server Administration 2
D The attachment filename.xls is open or in use by another application. Using Outlook 11
K Cannot start Microsoft Outlook. Cannot open the Outlook Window. Incompatible application Using Outlook 1
H Application stops running while I'm typing an email! Using Outlook 2
W 'Windows Application Error 0Xc00000a5” error opening attached files or email link in Outlook Using Outlook 1
P error message oxc00000a5 unable to open application. Using Outlook 1
F Need to fill an application and mail it. Using Outlook 1
M On exiting Outlook 7 the application recovers and restarts Using Outlook 2
7 Faulting application outlook.exe, Stamp 4bf5c678 Using Outlook 6
J Exchange 2010 Application error Exchange Server Administration 5
T outlook\outlook.pst\ is in use and could not be accessed. Close any application that is using this f Using Outlook 6
J access to 'Local Settings\Application Data\Microsoft\Outlook' folders in Win XP Using Outlook 1
J Outlook Social Connector listed as Inactive Application Add-In. Using Outlook 1
T Outlook 2007 Master Category List problem in combination with Citrix Published Application Using Outlook 2
J I want use Microsoft Outlook 2003 as my main mail application what kind of server type do i use, and how do I set it up Using Outlook 1
G Re: message in "Click-to-run Application Manager": Microsoft Outlook 2010 cannot be opened. Try agai Using Outlook 2
C Error Alert: "The file C:\Documents and Settings\name\Local Settings\Application Data\Microsoft\Outl Using Outlook 1
Y Missing Powershell Virtual Application in IIS7.5 (W2K8R2) Exchange Server Administration 2
M Faulting application outlook.exe__ Using Outlook 3
G Outlook '07 causes Event Errors 34 & 35 in the Application Log Using Outlook 4
R Outlook 7 application won't open. This worked ok until today. Using Outlook 0
T application error: search.exe Using Outlook 1
Similar threads


















































Top