![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]()
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 |
#3
|
|||
|
|||
![]()
What line does it bomb at when you debug?
The shown code works fine, but only for my private contacts. I wish to get the phonenumbers from on of the companies distributionlists ("All address lists" - "All Groups" - "Local list"). However I can't seem to define the folder correctly :-( Lars |
#4
|
|||
|
|||
![]()
GAL address lists are not Outlook folders. You can't use Outlook ContactItem properties with them. See http://www.outlookcode.com/codedetail.aspx?id=594 for a code sample showing how to retrieve a phone number with MAPI properties.
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Lars Thomsen Nielsen" wrote in message ... What line does it bomb at when you debug? The shown code works fine, but only for my private contacts. I wish to get the phonenumbers from on of the companies distributionlists ("All address lists" - "All Groups" - "Local list"). However I can't seem to define the folder correctly :-( Lars |
#5
|
|||
|
|||
![]()
See http://www.outlookcode.com/codedetail.aspx?id=594 for a
code sample showing how to retrieve a phone number with MAPI properties. Thanx Sue, I have found another workaround. I have used CDO. To get ALL the possible information on the person I have made the following code which saves a file for me with the relevant data and puts the for me most important data into variables. (I have cut a lot of the code out): Sub GetPersonData() Set myOutlook = CreateObject("Outlook.Application") Set myMailItem = myOutlook.CreateItem(0) myMailItem.Recipients.Add " Call ReadCDO_Var Call ReadCDO_VarKode Set cdoSession = CreateObject("Mapi.session") cdoSession.Logon , , False, False, 0 'Use the existing Outlook session. Set cdoAddrEntry = cdoSession.GetAddressEntry(myMailItem.Recipients.I tem(1).EntryID) Open StiOgFilNavn For Output As #3 For i = 1 To 453 DummyStreng = "" DummyStreng = cdoAddrEntry.Fields(CDO_VarKode(i)) If DummyStreng "" Then Print #3, i & vbTab & CDO_Var(i) Print #3, i & vbTab & DummyStreng Print #3, "" 'Debug.Print CDO_Var(i) & " = "; DummyStreng If CDO_Var(i) = "CdoPR_ACCOUNT" Then Initialer = DummyStreng If CDO_Var(i) = "CdoPR_BUSINESS_TELEPHONE_NUMBER" Then TlfNummer = DummyStreng If CDO_Var(i) = "CdoPR_DISPLAY_NAME" Then Fuldtnavn = DummyStreng If CDO_Var(i) = "CdoPR_GIVEN_NAME" Then Fornavn = DummyStreng If CDO_Var(i) = "CdoPR_SURNAME" Then Efternavn = DummyStreng If CDO_Var(i) = "CdoPR_TITLE" Then Titel = DummyStreng End If Next Close #3 End Sub Sub ReadCDO_Var() 'Tildeler variabelnavne med tilhørende CDO-kaldenavn CDO_Var(1) = "CdoPR_7BIT_DISPLAY_NAME" CDO_Var(2) = "CdoPR_AB_DEFAULT_DIR" CDO_Var(3) = "CdoPR_AB_DEFAULT_PAB" CDO_Var(4) = "CdoPR_AB_PROVIDER_ID" CDO_Var(5) = "CdoPR_AB_PROVIDERS" CDO_Var(6) = "CdoPR_AB_SEARCH_PATH" ..... CDO_Var(452) = "CdoPR_XPOS" CDO_Var(453) = "CdoPR_YPOS" End Sub Sub ReadCDO_VarKode() 'Tildeler variabelnavne med tilhørende CDO-kaldekode CDO_VarKode(1) = &H39FF001E CDO_VarKode(2) = &H3D060102 CDO_VarKode(3) = &H3D070102 CDO_VarKode(4) = &H36150102 CDO_VarKode(5) = &H3D010102 CDO_VarKode(6) = &H3D051102 ..... CDO_VarKode(452) = &H3F050003 CDO_VarKode(453) = &H3F060003 End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Finding contacts in Outlook Web Access | Kermit | Outlook - Using Contacts | 4 | April 16th 06 09:47 PM |
Finding Contacts in Company Order | CarolineP | Outlook - Using Contacts | 1 | March 29th 06 05:19 PM |
searching personel folders with subfolders ticked not finding contacts etc | Tim | Outlook - General Queries | 0 | February 8th 06 02:31 AM |
not finding names | BorisS | Outlook - Using Contacts | 1 | January 27th 06 06:01 PM |
Finding Contacts in Public Folders | Manowar | Outlook - Using Contacts | 3 | January 25th 06 12:39 AM |