p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   BOOK: Professional Outlook 2007 Programming ISBN: 978-0-470-04994-5 (http://p2p.wrox.com/book-professional-outlook-2007-programming-isbn-978-0-470-04994-5-363/)
-   -   Sub or Function not defined (http://p2p.wrox.com/book-professional-outlook-2007-programming-isbn-978-0-470-04994-5/87144-sub-function-not-defined.html)

dLRam March 31st, 2012 09:02 AM

Sub or Function not defined
 
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


All times are GMT -4. The time now is 11:06 AM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.