View Single Post
  #2  
Old May 23rd 06, 08:10 PM posted to microsoft.public.outlook.program_vba
Guy
external usenet poster
 
Posts: 12
Default Finding Phonenumber on contacts

What line does it bomb at when you debug?

--
Guy
Forefront Business Solutions
www.forefrontbusinesssolutions.com
www.forefrontbusiness.com


"Lars Thomsen Nielsen" wrote in message
...
Outlook2003. I would like to get the phonenumbers from the listed
persons in a distributionlist. However I have some problems
defining the right folder. The code below works for my personal
addressbook, but I wish to get it to work with a distribution
list called "All address lists" - "All Groups" - "Local list".
I constantly gets problems when trying to change the line with
GetDefaultFolder(olFolderContacts).

Could somebody please help me to get this to work?

Sub FindPhoneNumber()
Dim myOlApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myContacts As Outlook.Items
Dim myItems As Outlook.Items
Dim myItem As Object
Dim DummyName As String
Dim DummyPhone As String
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myContacts =
myNamespace.GetDefaultFolder(olFolderContacts).Ite ms
For Each myItem In myContacts
If (myItem.Class = olContact) Then
DummyName = myItem.FullName
DummyPhone = myItem.BusinessTelephoneNumber
End If
Next
End Sub


--
Best regards

Lars Thomsen Nielsen





Ads