|With Category-Manager you can group your Outlook categories, share them with other users, filter a folder by category, automatically categorize new emails, and more. You can use the Addin even for IMAP.|
In order to receive events of an object, you need to declare a variable with the keyword WithEvents in a class module. It's pretty simple as long as the user opens only one item at a time: Then you also need only one variable. Wait for the Newinspector event; if it triggers, you know a new items is going to be opened; if it's a MailItem, save the reference on it in the variable and then you'll receive the events from that MailItem. It's mre difficult in reality though because users often open more than just one item at a time. Since you don't know beforehand the amount of items to track, you cannot use, say, three variables. What, if the user opens four items?
Solve the issue by using a class module. Benefit of a class module is, you write the code only once and create as many instances, that is objects, of it as will be needed.
The following so called Inspector wrapper demonstrates how it works, it also shows the different situations when an item is being closed.
Paste the following code into the ThisOutlookSession module.
Private WithEvents m_Inspectors As Outlook.Inspectors Private m_MyInspectors As VBA.Collection Private m_lNextKey As Long Private Sub Application_Startup() Set m_Inspectors = Application.Inspectors Set m_MyInspectors = New VBA.Collection End Sub Private Sub m_Inspectors_NewInspector(ByVal Inspector As Outlook.Inspector) On Error Resume Next Dim oInspector As cInspector Set oInspector = New cInspector If oInspector.Init(Inspector, CStr(m_lNextKey)) Then m_MyInspectors.Add oInspector, CStr(m_lNextKey) m_lNextKey = m_lNextKey + 1 End If End Sub Friend Property Get MyInspectors() As VBA.Collection Set MyInspectors = m_MyInspectors End Property
|ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the e-mail.|
Add a new class module via Insert/Class Module. Press F4, and name the it 'cInspector'. Paste the entire following code into this new class module.
Private WithEvents m_Inspector As Outlook.Inspector Private WithEvents m_Mail As Outlook.MailItem Private m_IsClosed As Boolean Private m_sKey As String Friend Function Init(oInspector As Outlook.Inspector, _ sKey As String _ ) As Boolean Dim obj As Object If Not oInspector Is Nothing Then Set obj = oInspector.CurrentItem If TypeOf obj Is Outlook.MailItem Then Set m_Mail = obj Set m_Inspector = oInspector m_sKey = sKey Init = True End If End If End Function Private Sub m_Inspector_Close() CloseInspector End Sub Private Sub Class_Terminate() CloseInspector End Sub Friend Sub CloseInspector() On Error Resume Next If m_IsClosed = False Then m_IsClosed = True ThisOutlookSession.MyInspectors.Remove m_sKey Set m_Mail = Nothing Set m_Inspector = Nothing End If End Sub
|OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or e-mails.|
There is three ways to close an email:
A developer needs to know not only which events could be triggered but also the order of the events. The latter two are easy if the item is unchanged. From within Word (Outlook 2003) the Inspector_Close event is triggered first. From within Outlook in contrast the Item_Close event is triggered first. (Since Outlook 2007 you don't need to bother with the Word events.)
If the item was changed, the user gets prompted whether or not he wants to save the changes; the dialog also allows to cancel the closing. In this case our cInspector object shouldn't be closed, too.
Outlook 2000 was a problem because it didn't support the BeforeDelete. Thus it wasn't possible to identify if a user was going to delete a changed item.
Private Sub m_Mail_Send(Cancel As Boolean) On Error Resume Next CloseInspector End Sub
For the following function get also GetOutlookVersion.
Private Sub m_Mail_Close(Cancel As Boolean) On Error Resume Next If GetOutlookVersion < 10 Then CloseInspector ElseIf m_Mail.Saved Then CloseInspector End If End Sub
This event wasn't available before Outlook XP. If the item was changed, this event will be triggered after the Save dailog.
Private Sub m_Mail_BeforeDelete(ByVal Item As Object, Cancel As Boolean) CloseInspector End Sub
|VBOffice Reporter is an easy to use tool for data analysis and reporting in Outlook. A single click, for instance, allows you to see the number of hours planned for meetings the next month.|