Consulting

Results 1 to 7 of 7

Thread: Solved: Public Folders

  1. #1
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location

    Solved: Public Folders

    Does anyone know how I can pull contact info from the Public Folders? The structure is like

    outlook:\\Public Folders\All Public Folders\BB Phone Lists\Calgary List

    Thanks

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Hi there,

    I think this might help but my Outlook is down at the moment so I can't test it. Try pasting this sub into your "ThisOutlookSession" module in the Outlook VBEditor (Alt+F11) and see how it goes. This example should add the full name of each contact to a string then display the whole lot in a message box at the end.

    [VBA]Sub ListContacts()
    Dim ns As Outlook.NameSpace
    Dim TargetFolderItems As MAPIFolder
    Dim c As Outlook.ContactItem
    Dim tempstring as String

    'set the namespace
    Set ns = Application.GetNamespace("MAPI")
    'set your target folder
    Set TargetFolderItems = ns.Folders.Item("Personal Folders").Folders.Item("All Public Folders") _
    .Folders.Item("BB Phone Lists").Folders.Item("Calgary List")

    'loop through the items in the target folder and do something with them
    For Each c In objFolder.Items
    tempstring = tempstring & c.FullName & chr(13)
    Next
    MsgBox tempstring
    End Sub[/VBA]
    K :-)

  3. #3
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    Thank you Killian. I did some research with the board and I was able to get it to work. However, it does not look pretty. I did some Code Jacking and Frankenstein code to get it to work (some what). I was not able to get some of the fields that I wanted to retrieve. I will post and hopefully some one can point me to the right direction. The primary problem right now is that I don't know what the Field Names are called, I had to guess at the field names (for example - the Business Phone number - I just cannot retrieve it - due to I don't know the variable names is). Here is what I have:
    [VBA]
    Sub PublicList()
    Dim oOutlook, oSelection, oMessage, objCDOMsg, strEntryID, strStoreID, Atch
    Dim olNS, DelItemsFolder

    Dim myfolder4 As Outlook.mapiFolder
    Dim item As MAPI.AddressEntry
    Dim oFolder As MAPI.AddressList
    Dim objSession As Object

    Dim SndName As String, SndAddr As String, ToName As String, CCName As String
    Dim Subj As String, Rcvd As String, MsgBody As String, AtchName As String
    Dim AtchCell As Range, MsgCount As Integer, Cntr As Long, ws As Worksheet
    Dim ShtNm As String, fws As Worksheet
    ' OutlookImport.Hide
    Application.ScreenUpdating = False
    ' Set oOutlook = CreateObject("Outlook.Application")
    Set oOutlook = New Outlook.Application

    Set olNS = oOutlook.GetNamespace("MAPI")
    ' Set DelItemsFolder = olNS.GetDefaultFolder(3)
    On Error Resume Next
    ' Set oSelection = oOutlook.ActiveExplorer.Selection
    If Err.Number = 91 Then
    MsgBox "Outlook is not open, or another error has occurred. Exiting."

    End If
    On Error GoTo 0
    ' Set objSession = CreateObject("MAPI.Session")
    Set objSession = New MAPI.Session
    objSession.Logon "", "", False, False

    ' objSession.CdoAddressEntry

    Set MyFolder1 = olNS.Folders("Public Folders")
    Set MyFolder2 = MyFolder1.Folders("All Public Folders")
    Set myfolder3 = MyFolder2.Folders("BB Phone Lists")
    Set myfolder4 = myfolder3.Folders("Calgary List")

    ' MsgBox (myfolder4.Items.Session.CurrentUser)
    For i = 1 To myfolder4.Items.Count
    With myfolder4.Items.item(i)
    MsgBox (.FileAs)
    MsgBox (.Initials)
    MsgBox (.FullName)
    MsgBox (.FirstName)
    MsgBox (.LastName)
    MsgBox (.JobTitle)
    MsgBox (.BusinessAddress)
    MsgBox (.Department)
    MsgBox (.Email1DisplayName)
    MsgBox (.Email1Address)
    End With
    Next
    ' MsgBox (myfolder4.Session)
    End Sub

    [/VBA]

    I did alot of guess work - got the above fields, but it would be great if I can retrieve the Field Names

  4. #4
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    I think the one you're looking for is "BusinessTelephoneNumber"

    Here's a list of all ContactItem properties:

    Account Property
    Actions Property

    Anniversary Property

    Application Property

    AssistantName Property

    AssistantTelephoneNumber Property

    Attachments Property

    AutoResolvedWinner Property

    BillingInformation Property

    Birthday Property

    Body Property

    Business2TelephoneNumber Property

    BusinessAddress Property

    BusinessAddressCity Property

    BusinessAddressCountry Property

    BusinessAddressPostalCode Property

    BusinessAddressPostOfficeBox Property

    BusinessAddressState Property

    BusinessAddressStreet Property

    BusinessFaxNumber Property

    BusinessHomePage Property

    BusinessTelephoneNumber Property

    CallbackTelephoneNumber Property

    CarTelephoneNumber Property

    Categories Property

    Children Property

    Class Property

    Companies Property

    CompanyAndFullName Property

    CompanyLastFirstNoSpace Property

    CompanyLastFirstSpaceOnly Property

    CompanyMainTelephoneNumber Property

    CompanyName Property

    ComputerNetworkName Property

    Conflicts Property

    ConversationIndex Property

    ConversationTopic Property

    CreationTime Property

    CustomerID Property

    Department Property

    DownloadState Property

    Email1Address Property

    Email1AddressType Property

    Email1DisplayName Property

    Email1EntryID Property

    Email2Address Property

    Email2AddressType Property

    Email2DisplayName Property

    Email2EntryID Property

    Email3Address Property

    Email3AddressType Property

    Email3DisplayName Property

    Email3EntryID Property

    EntryID Property

    FileAs Property

    FirstName Property

    FormDescription Property

    FTPSite Property

    FullName Property

    FullNameAndCompany Property

    Gender Property

    GetInspector Property

    GovernmentIDNumber Property

    HasPicture Property

    Hobby Property

    Home2TelephoneNumber Property

    HomeAddress Property

    HomeAddressCity Property

    HomeAddressCountry Property

    HomeAddressPostalCode Property

    HomeAddressPostOfficeBox Property

    HomeAddressState Property

    HomeAddressStreet Property

    HomeFaxNumber Property

    HomeTelephoneNumber Property

    IMAddress Property

    Importance Property

    Initials Property

    InternetFreeBusyAddress Property

    IsConflict Property

    ISDNNumber Property

    ItemProperties Property

    JobTitle Property

    Journal Property

    Language Property

    LastFirstAndSuffix Property

    LastFirstNoSpace Property

    LastFirstNoSpaceAndSuffix Property

    LastFirstNoSpaceCompany Property

    LastFirstSpaceOnly Property

    LastFirstSpaceOnlyCompany Property

    LastModificationTime Property

    LastName Property

    LastNameAndFirstName Property

    Links Property

    MailingAddress Property

    MailingAddressCity Property

    MailingAddressCountry Property

    MailingAddressPostalCode Property

    MailingAddressPostOfficeBox Property

    MailingAddressState Property

    MailingAddressStreet Property

    ManagerName Property

    MarkForDownload Property

    MessageClass Property

    MiddleName Property

    Mileage Property

    MobileTelephoneNumber Property

    NetMeetingAlias Property

    NetMeetingServer Property

    NickName Property

    NoAging Property

    OfficeLocation Property

    OrganizationalIDNumber Property

    OtherAddress Property

    OtherAddressCity Property

    OtherAddressCountry Property

    OtherAddressPostalCode Property

    OtherAddressPostOfficeBox Property

    OtherAddressState Property

    OtherAddressStreet Property

    OtherFaxNumber Property

    OtherTelephoneNumber Property

    OutlookInternalVersion Property

    OutlookVersion Property

    PagerNumber Property

    Parent Property

    PersonalHomePage Property

    PrimaryTelephoneNumber Property

    Profession Property

    RadioTelephoneNumber Property

    ReferredBy Property

    Saved Property

    SelectedMailingAddress Property

    Sensitivity Property

    Session Property

    Size Property

    Spouse Property

    Subject Property

    Suffix Property

    TelexNumber Property

    Title Property

    TTYTDDTelephoneNumber Property

    UnRead Property

    User1 Property

    User2 Property

    User3 Property

    User4 Property

    UserCertificate Property

    UserProperties Property

    WebPage Property

    YomiCompanyName Property

    YomiFirstName Property

    YomiLastName Property
    K :-)

  5. #5
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    Thank you Killian, those field names are very handy. Saves me alot of guess work.

  6. #6
    VBAX Regular
    Joined
    Feb 2005
    Posts
    82
    Location

    Related question

    The code is pulling information from Contacts, correct? Is it possible to get this type of information from a Global Address book? I've only had success with Name and Manager and a few others but not Phone Number or Address.

    Thanks,
    Bill
    (And let me know if I should create this as a new thread instead of piggy- backing on this one)

  7. #7
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Bill,
    Welcome to VBAX
    Best to post a new question with a reference to this one.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •