Test whether the current folder is a Contacts folder:
If fld.DefaultItemType <> olContactItem Then
MsgBox _
“This folder is not a Contacts folder; canceling”
GoTo ErrorHandlerExit
End If
Set a reference to the currently open item, via the active Inspector:
Set ins = appOutlook.ActiveInspector
Set itm = ins.CurrentItem
Test whether the open item is a mail message, and set a mail message variable to it if so:
If itm.Class = olMail Then
Set msg = itm
End If
Set a reference to the contact whose name is “Helen Feddema”:
Set fld = nms.GetDefaultFolder(olFolderContacts)
Set con = fld.Items(“Helen Feddema”)
Set a reference to a built-in Outlook item property:
strFullName = con.FullName
Set a reference to a custom Outlook item property of the Yes/No data type:
blnCustomer = con.UserProperties(“Customer”)
Standard GetObjectline and error handler to default to CreateObjectin case Outlook is not
running:
Dim appOutlook As Outlook.Application
Set appOutlook = GetObject(, “Outlook.Application”)
[Your code here]
ErrorHandlerExit:
Exit Sub
ErrorHandler:
‘Outlook is not running; open Outlook with CreateObject
If Err.Number = 429 Then
Set appOutlook = CreateObject(“Outlook.Application”)
Working with Outlook Items 8