Ah. You don't really mean '
How do I detect that?', but rather '
How do I capture that event?'. There is a very real difference, as when the code gets control back the message is still open. At this point your code will then complete execution to allow the operator again to take control. Until another event triggers your code doesn't know anything and cannot even check any status.
The difficulty here is that, while you can handle events such as closing an Inspector window (Items are shown in Inspector windows btw), within Outlook, I'm not sure how that might be achieved from outside of Outlook.
If it's the same them you'd need to define your MailItem properly as :
- Private WithEvents VBAItem As MailItem
This will give you access to events for this item of both
Close and
Send.
- Private Sub VBAItem_Close(Cancel As Boolean)
-
End Sub
-
-
Private Sub VBAItem_Send(Cancel As Boolean)
-
End Sub
You can then recognise what happens - all assuming this method of handling events is supported outside of Outlook.
PS. Please see
[code] Tags Must be Used &
When Posting (VBA or SQL) Code.