📄 clsoutlookinspectorevents.cls
字号:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsOutlookInspectorEvents"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'*********************************************************************
' copyright 2002 by Martin Nemzow (mnemzow@networkperf.com)
' You can use this code freely and distribute it.
' No warrantee granted or implied.
' this is a very loose modification of Randy Byrne's CBITEMS OUTLOOK
' COM Add-In in order to trap inspector events along side explorer events
' and watch the sequence of the events. The debugger works with it.
'
'... yes you can use this to add CommandBar items. But note that I have
' changed some variable names and added new classes with longer names
' so that it cuold be debugged and make some sense for reading to me.
' You are welcome to correct anything you want and tell me.
' the comments with '[2002] remove functionality available only in
' OUTLOOK 2002 and in OUTLOOK 2000. I appreciate everyone's efforts to
' decode how to automate Outlook, so if you have comments and changes
' I would very much appreciate it, and I think others will too.
'*********************************************************************
Option Explicit
'**************************************************
'Class: clsOutlookInspectorEvents
'**************************************************
Private WithEvents objOutlook As Outlook.Application
Attribute objOutlook.VB_VarHelpID = -1
Private WithEvents colInspectors As Outlook.Inspectors
Attribute colInspectors.VB_VarHelpID = -1
Private WithEvents objInspector As Outlook.Inspector
Attribute objInspector.VB_VarHelpID = -1
Private WithEvents objMailItem As Outlook.MailItem
Attribute objMailItem.VB_VarHelpID = -1
Friend Sub InitHandler(olApp As Outlook.Application, strProgID As String)
Dim myAddIn As Office.COMAddIn
On Error Resume Next
Set objOutlook = olApp
Set gbl_objApplication = olApp
gbl_ProgID = strProgID
If colInspectors.Count >= 1 Then
Set colInspectors = objOutlook.Inspectors
AddInspector objOutlook.ActiveInspector
End If
Set objInspector = objOutlook.ActiveInspector
End Sub
Friend Sub UnInitHandler()
On Error Resume Next
Set colInspectors = Nothing
Set gbl_objApplication = Nothing
Set objOutlook = Nothing
Set objMailItem = Nothing
End Sub
Private Sub colInspectors_NewInspector(ByVal Inspector As Outlook.Inspector) 'Notifies your program that a new inspector window has been created.
Dim objItem As Object
On Error Resume Next
Set objInspector = Inspector
Set objItem = objInspector.CurrentItem
MsgBox "NewInspector: " & Inspector.Caption
AddInspector Inspector
Select Case objItem.Class
Case olAppointment
Case olContact
Case olDistributionList
Case olDocument
Case olJournal
Case olMail
Set objMailItem = objItem
MsgBox "message subject: " & objMailItem.Subject
Case olPost
Case olRemote
Case olReport
Case olTaskRequestAccept
Case olTaskRequestDecline
Case olTask
Case olTaskRequest
Case olTaskRequestAccept
Case olTaskRequestDecline
End Select
End Sub
Private Sub objMailItem_ItemAdd()
MsgBox "objMailItem_ItemAdd"
End Sub
Private Sub objMailItem_ItemChange()
MsgBox "objMailItem_ItemChange"
End Sub
Private Sub objMailItem_ItemOpen()
MsgBox "objMailItem_ItemOpen"
End Sub
Private Sub objMailItem_ItemRead()
MsgBox "objMailItem_ItemRead"
End Sub
Private Sub objMailItem_ItemRemove()
MsgBox "objMailItem_ItemRemove"
End Sub
Private Sub objMailItem_ItemReply()
MsgBox "objMailItem_ItemReply"
End Sub
Private Sub objMailItem_ItemSend()
MsgBox "objMailItem_ItemSend"
End Sub
Private Sub objMailItem_ItemWrite()
MsgBox "objMailItem_ItemWrite"
End Sub
'[2002]Private Sub objMailItem_AttachmentAdd()
'[2002] MsgBox "objMailItem_AttachmentAdd"
'[2002]End Sub
'[2002]Private Sub objMailItem_AttachmentRead()
'[2002] MsgBox "objMailItem_AttachmentRead"
'[2002]End Sub
Private Sub objMailItem_BeforeDelete()
MsgBox "objMailItem_BeforeDelete"
End Sub
'[2002]Private Sub objMailItem_BeforeAttachmentSave()
'[2002] MsgBox "objMailItem_BeforeAttachmentSave"
'[2002]End Sub
'[2002]Private Sub objMailItem_BeforeCheckNames()
'[2002] MsgBox "objMailItem_BeforeCheckNames"
'[2002]End Sub
'[2002]Private Sub objMailItem_Close()
'[2002] MsgBox "objMailItem_Close"
'[2002]End Sub
Private Sub objMailItem_Delete()
MsgBox "objMailItem_Delete"
End Sub
'[2002]Private Sub objMailItem_Forward()
'[2002] MsgBox "objMailItem_Forward"
'[2002]End Sub
'[2002]Private Sub objMailItem_Open()
'[2002] MsgBox "objMailItem_Open"
'[2002]End Sub
'[2002]Private Sub objMailItem_PropertyChange(ByVal PropertyName As Object)
'[2002] Select Case PropertyName
'[2002] Case "Sensitivity"
'[2002] Item.Subject = "The sensitivity value has changed."
'[2002] End Select
'[2002] SubMsgBox "objMailItem_PropertyChange"
'[2002]End Sub
Private Sub objMailItem_Read()
MsgBox "objMailItem_Read"
End Sub
'[2002]Private Sub objMailItem_Reply()
'[2002] MsgBox "objMailItem_Reply"
'[2002]End Sub
'[2002]Private Sub objMailItem_ReplyAll()
'[2002] MsgBox "objMailItem_ReplyAll"
'[2002]End Sub
Private Sub objMailItem_Send(Cancel As Boolean)
MsgBox "objMailItem_Send"
If objMailItem.Subject = "" Then
If objMailItem.Subject = "" Then
Cancel = True
End If
End If
End Sub
'[2002]Private Sub objMailItem_Write()
'[2002] MsgBox "objMailItem_Write"
'[2002]End Sub
Private Sub objOutlook_Startup()
On Error Resume Next
MsgBox "objStartup_Startup."
If colInspectors.Count Then
AddInspector objOutlook.ActiveInspector
End If
End Sub
'
'
'
'
'
'
Private Sub colInspectors_Activate() 'Notifies your program that an explorer or inspector window has become the active window.
MsgBox "Inspectors_Activate."
End Sub
'Private Sub colInspectors_BeforeFolderSwitch() 'Notifies your program that the user has attempted to change the folder displayed by an explorer. Your program can cancel the event to prevent the change.
'
'End Sub
'Private Sub colInspectors_BeforeGroupAdd() 'Notifies your program that the user has attempted to add a group to the Outlook Bar. Your program can cancel the event to prevent the change.
'
'End Sub
'Private Sub colInspectors_BeforeGroupRemove() 'Notifies your program that the user has attempted to remove a group from the Outlook Bar. Your program can cancel the event to prevent the change.
'
'End Sub
'Private Sub colInspectors_BeforeGroupSwitch() 'Notifies your program that the user has attempted to change the group displayed in the Outlook Bar. Your program can cancel the event to prevent the change.
'
'End Sub
'Private Sub colInspectors_BeforeShortcutAdd() 'Notifies your program that the user has attempted to add a shortcut to the Outlook Bar. Your program can cancel the event to prevent the change.
'
'End Sub
'Private Sub colInspectors_BeforeShortcutRemove() 'Notifies your program that the user has attempted to remove a shortcut from the Outlook Bar. Your program can cancel the event to prevent the change.
'
'End Sub
'Private Sub colInspectors_BeforeViewSwitch() 'Notifies your program that the user has attempted to change the view used to display the contents of a folder in an explorer window. Your program can cancel the event to prevent the change.
'
'End Sub
Private Sub colInspectors_Deactivate() 'Notifies your program that an explorer or inspector window is no longer the active window.
MsgBox "Inspectors_Activate."
End Sub
'Private Sub colInspectors_FolderAdd() 'Notifies your program that a folder has been added to a specific folders collection.
'
'End Sub
'Private Sub colInspectors_FolderChange() 'Notifies your program that a folder in a specific folders collection has been changed.
'
'End Sub
'Private Sub colInspectors_FolderRemove() 'Notifies your program that a folder has been deleted from a specific folders collection.
'
'End Sub
'Private Sub colInspectors_FolderSwitch() 'Notifies your program that the user has changed the folder displayed by an explorer window.
'
'End Sub
'Private Sub colInspectors_GroupAdd() 'Notifies your program that a group has been added to the Outlook Bar.
'
'End Sub
Private Sub colInspectors_ItemAdd() 'Notifies your program that an item has been added to a specific items collection.
End Sub
Private Sub colInspectors_ItemChange() 'Notifies your program that an item in a specific items collection has been changed.
MsgBox "Inspectors_ItemChange."
End Sub
Private Sub colInspectors_ItemRemove() 'Notifies your program that an item has been deleted from a specific items collection.
MsgBox "Inspectors_ItemRemove."
End Sub
Private Sub colInspectors_ItemSend() 'Notifies your program that the user has attempted to send an item. Your program can cancel the event to prevent the item from being sent.
MsgBox "Inspectors_ItemSend."
End Sub
Private Sub colInspectors_NewMail() 'Notifies your program that new items have been delivered to the Inbox.
MsgBox "Inspectors_NewMail."
End Sub
'Private Sub colInspectors_OnError() 'Notifies your program that an error occurred during folder synchronization.
'
'End Sub
'Private Sub colInspectors_OptionsPagesAdd() 'Notifies your program that new options pages have been added to a property or options dialog box.
'
'End Sub
'Private Sub colInspectors_Progress() 'Notifies your program of the status of folder synchronization.
'
'End Sub
'Private Sub colInspectors_Reminder() 'Notifies your program that a reminder is about to be displayed.
'
'End Sub
'Private Sub colInspectors_ShortcutAdd() 'Notifies your program that a shortcut has been added to the Outlook Bar.
'
'End Sub
'Private Sub colInspectors_SyncStart() 'Notifies your program that Outlook has begun synchronizing the user抯 folders.
'
'End Sub
'Private Sub colInspectors_SyncEnd() 'Notifies your program that Outlook has finished synchronizing the user抯 folders
'
'End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -