Export all items in the Global address list

G

Guest

Thanks for taking the time to read my question.

I've done quite a bit of coding in MS Access and Excel, but never in
Outlook. I'd like to export all the items in the GAL to something like an
Excel file, or even a .csv. I have no idea where to start or finish. I've
been looking on line for a while but haven't found anything I understand.
I'm self taught in VBA, and know enough to get done what I need to.

Any help would be really appreciated.

Brad
 
G

Guest

Here is what I have so far. How do I get all the other e-mail address
associated with each entry?

Thanks,

Brad



Sub GetGAL()
Dim x As Integer
Dim gal As String

On Error GoTo GetGAL_Err

Set myAddressList = Application.Session.AddressLists("Global Address
List").AddressEntries

Open "C:\Documents and Settings\Mcintybd\Desktop\EmailInfo.txt" For Output
As #1 ' Open file for output.
x = 1
Do Until x = 4000
Print #1, myAddressList(x).Details
'Debug.Print NextItem
x = x + 1
Loop
Close #1

GetGAL_Exit:
Exit Sub

GetGAL_Err:
MsgBox Err.Number & ", " & Err.Description
If Err.Number = 55 Then
Close #1
Resume
Else
Resume GetGAL_Exit
End If
End Sub
 
S

Sue Mosher [MVP-Outlook]

Short answer: You don't. The data you can return with Outlook objects is limited to the Exchange address, the user name, and the manager name.

That's why I suggested that you use ADSI/LDAP. In that other sample, this is the statement that tells the script what to export:

com.CommandText = "select givenname, sn,objectCategory,objectClass, mail,msExchHideFromAddressLists _
& from '" & LDAPQUERY & "' where objectClass= 'user' order by sn " _

& or objectClass= 'contact' order by sn"

An ADSI/LDAP reference or the microsoft.public.exchange.development newsgroup can probably help you out with the other field names you might be looking for. It's not information I have at my fingertips here, since it's not directly Outlook related.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top