VBOffice

NewInspector and Inspector_Activate

Some emal properties cannot yet be changed in the Newinspector event. See how to handle that situation.

Last modified: 2007/03/20 | Accessed: 68.697  | #47
◀ Previous sample Next sample ▶
ReplyAll ReplyAll
ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the e-mail.

The NewInspector event fires when a new item is being created. So, that seems to be the time to edit the item, e.g. add a text to the item's body.

But there're object properties that aren't available yet. For instance, if you edit the item's Subject in NewInspector you won't see the change. The solution is using the Inspector's Activate event instead.

(It wouldn't be Outlook if there were no exception: Taskitems can and must be edited in the NewInspector event, they don't fire the very first Activate event.)


tip  How to add macros to Outlook
Private WithEvents m_Inspectors As Outlook.Inspectors
Private WithEvents m_Inspector As Outlook.Inspector

Private Sub Application_Startup()
  Set m_Inspectors = Application.Inspectors
End Sub

Private Sub m_Inspectors_NewInspector(ByVal Inspector As Outlook.Inspector)
  If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
    'Handle emails only
    Set m_Inspector = Inspector
  End If
End Sub

Private Sub m_Inspector_Activate()
  Dim Mail As Outlook.MailItem
  Set Mail = m_Inspector.CurrentItem
  If Len(Mail.EntryId) = 0 Then
    'Edit the subject only for new emails
    Mail.Subject = "test"
  End If
  Set m_Inspector = Nothing
End Sub
Category-Manager Category-Manager
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.
email  Send a message