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.
Similar threads
Thread starter Title 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
R Exchange 2010 setup failed: The application has failed to start because its side-by-side configuration is incorrect. 0x800736B1 Exchange Server Administration 3
K Handling application.quit event Outlook VBA and Custom Forms 8
A turn Outlook into a Drag-and-drop application Outlook Wishlist 2
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
L Sudden problem with sending receiving att.net e-mail account accessed through outlook 2007 Using Outlook 3
R Send/Receive error Outlook Data File Cannot be accessed Using Outlook 9
B "....pst cannot be accessed because another workstation has modified it. close and then restart all Using Outlook 1
A Outlook 2010 - can't send/receive data file cannot be accessed Using Outlook 10
S Hotmail account accessed by Outlook not receiving new email Using Outlook 7
A 0x8004010F 'Outlook data file cannot be accessed' Using Outlook 34
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

Top