Link to home
Start Free TrialLog in
Avatar of edmacey
edmacey

asked on

projectwrapper and inspectors- help with Outlook VBA

I am trying to get the inspectors event to look for two different activities, is this the correct code

Option Explicit
Dim WithEvents inspectors As inspectors
Dim WithEvents project As TaskItem
Dim root As folder

Private Sub Application_Startup()
    Set inspectors = Application.inspectors
    Set root = Application.Session.Folders("Business Contact Manager")
    Set project = root.Folders("Business Projects").items(1)
End Sub
Private Sub inspectors_NewInspector(ByVal inspector As inspector)
    If inspector.CurrentItem.Class <> olTask Then Exit Sub
    Dim oTaskItem As TaskItem
    Set oTaskItem = inspector.CurrentItem
    If oTaskItem.MessageClass <> "IPM.Task.BCM.Project" Then Return
    Dim oProjectWrapper As New ProjectWrapper
    oProjectWrapper.Init inspector
    If oTaskItem.MessageClass <> "IPM.Task.BCM.ProjectTask" Then
    Dim oTaskWrapper As New ProjectWrapper
    oTaskWrapper.Init inspector
End Sub

I did have a second Return after Then from the ProjectTask bit but it threw an error.
Should my class modules be called ProjectWrapper and TaskWrapper or have I got it all a bit confused?

Thanks Ed.
ASKER CERTIFIED SOLUTION
Avatar of peakpeak
peakpeak
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of edmacey
edmacey

ASKER

Thanks PeakPeak, I have actually now accomplished this and did intend just to cancel the question. I have often visited outlookcode.com which is why I only put good for the grade. Ed.