PDA

View Full Version : Solved: Public Folders



JKwan
03-14-2005, 03:49 PM
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

Killian
03-16-2005, 05:01 PM
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.

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

JKwan
03-17-2005, 08:47 AM
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:

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



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

Killian
03-22-2005, 03:03 AM
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

JKwan
03-22-2005, 10:07 AM
Thank you Killian, those field names are very handy. Saves me alot of guess work.

wnazzaro
09-20-2006, 03:25 PM
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)

mdmackillop
09-23-2006, 04:56 AM
Hi Bill,
Welcome to VBAX
Best to post a new question with a reference to this one.