EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
Go Back  Xtreme Visual Basic Talk > > > EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses


Reply
 
Thread Tools Display Modes
  #1  
Old 12-12-2002, 02:06 AM
ohmyigod
Guest
 
Posts: n/a
Question EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses


Hi
I want to display all the entries of MS Exchange Global Address List (GAL) in the following format

Name Email Address
=======================
John Mcenzie john@xyz.com
Ron Stewart ron@xyz.com

This requirement looks quite simple and the problem that I am facing is not in retrieving values from GAL but is in the ADRESS FORMAT in which I'm getting the "Email Address" from AddressEntry Object.

I'm using 'Address' method of the AddressEntry object and returns me the adddress in following format.

/o=XYZ Corporation/ou=ae/cn=Recipients/cn=john Mcenzie

and the Address Type for the above address is 'EX' which I guess is the abbrev. for 'Exchange' format.

Can anyone please tell me how can I display it in a SMTP format (john@xyz.com)?

Source Code
----------------
Private Sub cmdDisplay_Click()
Dim objmapiSession As MAPI.Session
Dim objmapiAddressList As AddressList
Dim objmapiAddressEntries As AddressEntries
Dim objmapiAddressEntry As AddressEntry
' Create a new MAPI Session
Set objmapiSession = New MAPI.Session

'Logon to the MS Exchange server
objmapiSession.Logon

'Get the Global Address List
Set objmapiAddressList = objmapiSession.GetAddressList(CdoAddressListGAL)

'Get the Addresses Collection
Set objmapiAddressEntries = objmapiAddressList.AddressEntries

' Loop through each address object
For Each objmapiAddressEntry In objmapiAddressEntries
Debug.Print objmapiAddressEntry.Name + vbTab + "(" + objmapiAddressEntry.Address + ")"
Next
'Log off
objmapiSession.Logoff

Set objmapiSession = Nothing
Set objmapiAddressList = Nothing
End Sub
Reply With Quote
  #2  
Old 04-28-2003, 12:47 PM
pliant pliant is offline
Freshman
 
Join Date: Jan 2003
Posts: 37
Default

Yes I am having the same problem using this code:

Private Sub GetOutlookAddressBook()

' Need to add reference to Outlook
'(In VBA editor Tools References MS Outlook #.# Library)
' Adds addresses to existing Sheet called Address and
' defines name Addresses containing this list
' For use with data Validation ListBox (Source as =Addresses)

On Error GoTo error

Dim objOutlook As Outlook.Application
Dim objAddressList As Outlook.AddressList
Dim objAddressEntry As Outlook.AddressEntry
Dim intCounter As Integer

' Setup connection to Outlook application
Set objOutlook = CreateObject("Outlook.Application")

Application.EnableEvents = False
Set objAddressList = objOutlook.Session.AddressLists("Recipients")


' Clear existing list
Sheets("Address").Range("A:A").Clear

'Step through each contact and list each that has an email address
For Each objAddressEntry In objAddressList.AddressEntries
If objAddressEntry.Address <> "" Then
intCounter = intCounter + 1
Application.StatusBar = "Address no. " & intCounter & " ... " & objAddressEntry.Address
Sheets("Address").Cells(intCounter, 1) = objAddressEntry.Address
DoEvents
End If
Next objAddressEntry

' Define range called "Addresses" to the list of emails
Sheets("Address").Cells(1, 1).Resize(intCounter, 1).Name = "Addresses"
error:
Set objOutlook = Nothing
Application.StatusBar = False
Application.EnableEvents = False
End Sub

---------------------------------------------------------------------

And also i need to get to an address list that is under a few headings:

Global Address List
Enterprise
Messaging1
Recipients
Messaging2
Recipients
-addresses here-

When i use:
Set objAddressList = objOutlook.Session.AddressLists("Recipients")

it gets the recipients under Messaging1 and not Message2 which are the ones i want and the addresses it does return are in the format as specified in the previous posting.
Reply With Quote
  #3  
Old 04-29-2003, 04:01 AM
JordanChrisEMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses JordanChris is offline
Senior Contributor

* Expert *
 
Join Date: Jan 2003
Location: Newbury, UK
Posts: 1,092
Default

The EX format is correct. It shows the internal, Exchange format, addressable items. It is how Exchange can identify the different mailboxes within its database. It IS the correct format for the users.

Some users can (but don't have to) have one or more SMTP addresses associated with their e-mail mailbox. These addresses allow messages from outside the Exchange environment to be delivered to a mailbox. These addresses, however, are NOT the name of the mailbox.

If you want to access the SMTP addresses, you will need to use something other than Simple MAPI or the Outlook API interfaces.
If you are using Exchange 2000, then the ADSI interfaces into the Active Directory are probably the easiest (see details on the MS / MSDN website). Otherwise, CDO might be useful (see www.CDOlive.com).
Reply With Quote
  #4  
Old 04-30-2003, 02:50 PM
pliant pliant is offline
Freshman
 
Join Date: Jan 2003
Posts: 37
Default

ok some more info:

Code:
 
  Dim objOutlook As Outlook.Application
  Dim objAddressList As Outlook.AddressList
  Dim objAddressEntry As Outlook.AddressEntry
  Dim intCounter As Integer
  Dim counter As Integer
  Dim addrCount As Integer
  
  ' Setup connection to Outlook application
  Set objOutlook = CreateObject("Outlook.Application")
  Set objAddressList = objOutlook.Session.AddressLists("Global Address List")
  
  'number of address lists in Global Address List
  addrCount = objOutlook.Session.AddressLists.Count
  MsgBox ("addrCount = " & addrCount)
  
  'print out the name of each address list in column
  For Each objAddressList In objOutlook.Session.AddressLists
    counter = counter + 1
    Sheets("Address").Cells(counter, 2) = objAddressList.Name
  Next objAddressList
By using the above i was able to determine that the index of the address list i wish to make use of is 526 so i can use the following to obtain a list of the addresses in it:

Code:
Set objAddressList = objOutlook.Session.AddressLists(526)

 For Each objAddressEntry In objAddressList.AddressEntries
        intCounter = intCounter + 1
        Sheets("Address").Cells(intCounter, 1) = objAddressEntry.Name               
        DoEvents
  Next objAddressEntry
However, if an address list is added to or deleted from the Global Address List this index number will change and the results will no longer be accurate. However, i can't specify the name of the address list due the problem listed above (duplicate address list names in different locations)

Is there a more reliable way to reference the address list than through using the index number??
Reply With Quote
  #5  
Old 05-01-2003, 02:54 AM
JordanChrisEMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses JordanChris is offline
Senior Contributor

* Expert *
 
Join Date: Jan 2003
Location: Newbury, UK
Posts: 1,092
Default

This line:
Set objAddressList = objOutlook.Session.AddressLists(526)

could be replaced wth a line like:
Set objAddressList = objOutlook.Session.AddressLists("My List Name")

But if you have duplicate names, then you could be in trouble.

Maybe (unsure here) you could do:
For each AddrList in objOutlook.Session.AddressLists("My List Name")
and step through the lists?

Or (slower):
For each AddrList in objOutlook.Session.AddressLists
If AddrList.Name = "My List Name" then...
Reply With Quote
  #6  
Old 05-02-2003, 10:34 AM
pliant pliant is offline
Freshman
 
Join Date: Jan 2003
Posts: 37
Default

ok i figured that part out using the ID and discovered outlook must be open for this too work...i can detect outlook using:

On Error Resume Next
If GetObject(, "Outlook.Application") Is Nothing Then
'Outlook is not running
End If

Now would there be anyway to access the Global Address Book in Outlook through using code to start some service in case the user does not have Outlook open. Or must the user manually open the Outlook application before the list can be updated?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
 
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses
 
-->