Inspectors.Add Method (Outlook)
Creates a new inspector window.
Syntax
expression .AddItem
expression A variable that represents an Inspectors object.
Parameters
Name |
Required/Optional |
Data Type |
Description |
---|---|---|---|
Item |
Required |
Object |
The item to display in the inspector window when it is created. |
Return Value
An Inspector object that represents a new inspector window.
Remarks
This method is essentially identical to the GetInspector property of an Outlook item, such as MailItem.
Example
This Microsoft Visual Basic for Applications (VBA) example prompts the user for a company name, uses the Restrict method to locate all contact items in the Contacts folder with that name, and displays each one.
Sub DisplayMyContacts()
Dim myFolder As Folder
Dim myItems As Items
Dim myRestrictItems As Items
Dim answer As String
Dim filter As String
Dim myInspector As Inspector
Dim x As Integer
answer = InputBox("Enter the company name")
Set myFolder = Application.GetNamespace("MAPI") _
.GetDefaultFolder(olFolderContacts)
filter = "[MessageClass] = 'IPM.Contact' AND [CompanyName] = '" & answer & "'"
Set myItems = myFolder.Items
Set myRestrictItems = myItems.Restrict(filter)
For x = 1 To myRestrictItems.Count
Set myInspector = Application.Inspectors.Add(myRestrictItems.Item(x))
myInspector.Display
Next x
End Sub