Hello
I am new to VBA and I have read âoutlook 2007 programmingâ. When I run the code below (the code is from the book) I receive a compile error, "Sub or Function not defined." And the âPublic Sub AddRecipient()â gets Highlighted. Also âSetDefaultDisplayMode_â is highlighted with a blue background. Can someone tell me what the problem may be?
Code:
Public Sub AddRecipient()
Dim oSelect As Outlook.SelectNamesDialog
Dim colRecipients As Outlook.Recipients
Dim oRecip As Outlook.Recipient
Dim oMail As Outlook.MailItem
Set oMail = Application.CreateItem(olMailItem)
Set oSelect = Application.Session.GetSelectNamesDialog
With oSelect
.AllowMultipleSelection = False
SetDefaultDisplayMode _
OlDefaultSelectNamesDisplayMode.olDefaultMail
.ForceResolution = True
.Caption = "My Mail Selector Dialog"
.ToLabel = "My To Selector"
.NumberOfRecipientSelectors = _
OlRecipientSelectors.olShowTo
.Display
If .Recipients.Count = 1 Then
Set oRecip = _
oMail.Recipients.Add(.Recipients.Item(1).Name)
End If
End With
oMail.Display
End Sub]
Thank you in advance for your help