Using Outlook Library to extract SMTP addresses 
Author Message
 Using Outlook Library to extract SMTP addresses

I want to retrieve the SMTP addresses from address
entries in my global address list using the outlook
library.

I can access all of the address entries just fine.  I can
read the names, etc.  But, when I read the address
property from my address entry (as an example), I get:

/o=DORISINC/ou=first administrative
group/cn=Recipients/cn=RaneyE


address)!  I have looked through the object library and
cannot find this anywehre!

Please help ... I am desperate!!!

Thanks,
Raney



Sun, 24 Jul 2005 23:48:09 GMT  
 Using Outlook Library to extract SMTP addresses
If CDO can be your choice, please check the article:

HOWTO: Retrieve Alternate E-mail Addresses Using CDO
http://support.microsoft.com/support/kb/articles/q196/5/07.asp

Sincerely,

Alick Ye, MCSD
Product Support Services
Microsoft Corporation
Get Secure! - <www.microsoft.com/security>

This posting is provide "AS IS" with no warranties, and confers no rights.

--------------------
Content-Class: urn:content-classes:message


X-Tomcat-NG: microsoft.public.vb.com

I want to retrieve the SMTP addresses from address
entries in my global address list using the outlook
library.

I can access all of the address entries just fine.  I can
read the names, etc.  But, when I read the address
property from my address entry (as an example), I get:

/o=DORISINC/ou=first administrative
group/cn=Recipients/cn=RaneyE


address)!  I have looked through the object library and
cannot find this anywehre!

Please help ... I am desperate!!!

Thanks,
Raney



Tue, 26 Jul 2005 16:28:05 GMT  
 Using Outlook Library to extract SMTP addresses

| I want to retrieve the SMTP addresses from address
| entries in my global address list using the outlook
| library.
|
| I can access all of the address entries just fine.  I can
| read the names, etc.  But, when I read the address
| property from my address entry (as an example), I get:
|
| /o=DORISINC/ou=first administrative
| group/cn=Recipients/cn=RaneyE
|

| address)!  I have looked through the object library and
| cannot find this anywehre!
|
| Please help ... I am desperate!!!
|
| Thanks,
| Raney

Hi Raney,

I experimented with extracting SMTP addresses from the GAL on our Exchange
Server several months ago. It's probably not the way you wanted to do it,
but it may give you ideas.

'Enum ActMsgDisplayType
Const ActMsgUser = 0
Const ActMsgDistList = 1
Const ActMsgForum = 2
Const ActMsgAgent = 3
Const ActMsgOrganization = 4
Const ActMsgPrivateDistList = 5
Const ActMsgRemoteUser = 6

Const CdoPR_EMS_AB_HOME_MTA = &H8007001E
Const CdoPR_EMS_AB_PROXY_ADDRESSES = &H800F101E

Public Sub AddressBooks()

    Dim objSession As Object                               'MAPI.Session
    Dim collAddressEntries As Object                       'AddressEntries

    On Error GoTo error_olemsg

    ' create a session and log on
    Set objSession = CreateObject("MAPI.Session")

    ' use a valid exchange profile name
    objSession.Logon "Microsoft Outlook"

    ' Walk the Global Address List
    Set collAddressEntries = objSession.AddressLists("Global Address
List").AddressEntries

    WalkAddressList collAddressEntries

    'close session and logoff
    objSession.Logoff

    Exit Sub
error_olemsg:
    MsgBox "Error " & Str(Err) & ": " & Error$(Err)
End Sub

Private Sub WalkAddressList(collAddressEntries As Object)
    ' Walk an AddressEntries collection recursively expanding Distribution
Lists

    On Error Resume Next

    Dim objAddressEntry As Object               'AddressEntry
    Dim objField As Object      'Field
    Dim n As Long
    Dim v As Variant
    Dim sName As String
    Dim sAddress As String
    Dim sType As String
    Dim sSMTP As String
    Dim s As String

    For Each objAddressEntry In collAddressEntries
        s = ""

        If objAddressEntry.DisplayType = ActMsgUser Then

            ' Display the recipient's name
            sName = Trim$(objAddressEntry.Name)
            Select Case True
                Case InStr(sName, "(E-mail") > 0
                    Debug.Print sName,
                    s = s & sName & vbTab
                Case InStr(sName, "(Business Fax") > 0
                    sName = ""
                Case InStr(sName, "(Other Fax") > 0
                    sName = ""
                Case Else
                    Debug.Print sName,
                    s = s & sName & vbTab
            End Select

            If Len(sName) Then
                sAddress = Trim$(objAddressEntry.Address)
                If InStr(sAddress, "/o=") > 0 Then
                    sSMTP = ""
                Else
                    sSMTP = sAddress                       'is this a valid
e-mail address?
                    Debug.Print sAddress,
                    s = s & sSMTP & vbTab
                End If

                'Q196507
                ' Get the PR_EMS_AB_PROXY_ADDRESSES property.
                Set objField =
objAddressEntry.Fields(CdoPR_EMS_AB_PROXY_ADDRESSES)

                If Err = 0 Then
                    ' PR_EMS_AB_PROXY_ADDRESSES is a multivalued property
(PT_MV_TSTRING).
                    ' Therefore, you need to extract the individual members.
                    For Each v In objField.Value
                        n = InStr(v, ":")
                        If n > 0 Then
                            sType = Left$(v, n - 1)

                            If sType = "SMTP" Then
                                sSMTP = Trim$(Mid$(v, n + 1))
                                Debug.Print sSMTP,
                                s = s & sSMTP & vbTab
                            End If
                        End If
                    Next
                End If

                Debug.Print
            End If

        ElseIf objAddressEntry.DisplayType = ActMsgDistList Then

            WalkAddressList objAddressEntry.Members

        End If

        If Len(s) Then
            'AppendToFile App.Path & "\gal.txt", s
        End If

    Next objAddressEntry

End Sub



Tue, 26 Jul 2005 21:25:21 GMT  
 Using Outlook Library to extract SMTP addresses
Will this work with Outlook Express?????  The code looks
OK to me.  Is it using the latest versio of CDO?

Thanks in advance,
Raney

Quote:
>-----Original Message-----


>| I want to retrieve the SMTP addresses from address
>| entries in my global address list using the outlook
>| library.
>|
>| I can access all of the address entries just fine.  I
can
>| read the names, etc.  But, when I read the address
>| property from my address entry (as an example), I get:
>|
>| /o=DORISINC/ou=first administrative
>| group/cn=Recipients/cn=RaneyE
>|

>| address)!  I have looked through the object library and
>| cannot find this anywehre!
>|
>| Please help ... I am desperate!!!
>|
>| Thanks,
>| Raney

>Hi Raney,

>I experimented with extracting SMTP addresses from the
GAL on our Exchange
>Server several months ago. It's probably not the way you
wanted to do it,
>but it may give you ideas.

>'Enum ActMsgDisplayType
>Const ActMsgUser = 0
>Const ActMsgDistList = 1
>Const ActMsgForum = 2
>Const ActMsgAgent = 3
>Const ActMsgOrganization = 4
>Const ActMsgPrivateDistList = 5
>Const ActMsgRemoteUser = 6

>Const CdoPR_EMS_AB_HOME_MTA = &H8007001E
>Const CdoPR_EMS_AB_PROXY_ADDRESSES = &H800F101E

>Public Sub AddressBooks()

>    Dim objSession As

Object                               'MAPI.Session
Quote:
>    Dim collAddressEntries As

Object                       'AddressEntries

- Show quoted text -

Quote:

>    On Error GoTo error_olemsg

>    ' create a session and log on
>    Set objSession = CreateObject("MAPI.Session")

>    ' use a valid exchange profile name
>    objSession.Logon "Microsoft Outlook"

>    ' Walk the Global Address List
>    Set collAddressEntries = objSession.AddressLists
("Global Address
>List").AddressEntries

>    WalkAddressList collAddressEntries

>    'close session and logoff
>    objSession.Logoff

>    Exit Sub
>error_olemsg:
>    MsgBox "Error " & Str(Err) & ": " & Error$(Err)
>End Sub

>Private Sub WalkAddressList(collAddressEntries As Object)
>    ' Walk an AddressEntries collection recursively

expanding Distribution
Quote:
>Lists

>    On Error Resume Next

>    Dim objAddressEntry As

Object               'AddressEntry

- Show quoted text -

Quote:
>    Dim objField As Object      'Field
>    Dim n As Long
>    Dim v As Variant
>    Dim sName As String
>    Dim sAddress As String
>    Dim sType As String
>    Dim sSMTP As String
>    Dim s As String

>    For Each objAddressEntry In collAddressEntries
>        s = ""

>        If objAddressEntry.DisplayType = ActMsgUser Then

>            ' Display the recipient's name
>            sName = Trim$(objAddressEntry.Name)
>            Select Case True
>                Case InStr(sName, "(E-mail") > 0
>                    Debug.Print sName,
>                    s = s & sName & vbTab
>                Case InStr(sName, "(Business Fax") > 0
>                    sName = ""
>                Case InStr(sName, "(Other Fax") > 0
>                    sName = ""
>                Case Else
>                    Debug.Print sName,
>                    s = s & sName & vbTab
>            End Select

>            If Len(sName) Then
>                sAddress = Trim$(objAddressEntry.Address)
>                If InStr(sAddress, "/o=") > 0 Then
>                    sSMTP = ""
>                Else
>                    sSMTP =

sAddress                       'is this a valid
Quote:
>e-mail address?
>                    Debug.Print sAddress,
>                    s = s & sSMTP & vbTab
>                End If

>                'Q196507
>                ' Get the PR_EMS_AB_PROXY_ADDRESSES
property.
>                Set objField =
>objAddressEntry.Fields(CdoPR_EMS_AB_PROXY_ADDRESSES)

>                If Err = 0 Then
>                    ' PR_EMS_AB_PROXY_ADDRESSES is a

multivalued property

- Show quoted text -

Quote:
>(PT_MV_TSTRING).
>                    ' Therefore, you need to extract the
individual members.
>                    For Each v In objField.Value
>                        n = InStr(v, ":")
>                        If n > 0 Then
>                            sType = Left$(v, n - 1)

>                            If sType = "SMTP" Then
>                                sSMTP = Trim$(Mid$(v, n
+ 1))
>                                Debug.Print sSMTP,
>                                s = s & sSMTP & vbTab
>                            End If
>                        End If
>                    Next
>                End If

>                Debug.Print
>            End If

>        ElseIf objAddressEntry.DisplayType =
ActMsgDistList Then

>            WalkAddressList objAddressEntry.Members

>        End If

>        If Len(s) Then
>            'AppendToFile App.Path & "\gal.txt", s
>        End If

>    Next objAddressEntry

>End Sub

>.



Tue, 26 Jul 2005 21:36:40 GMT  
 Using Outlook Library to extract SMTP addresses
The code uses any version of CDO. As you can see, I used the article Alick
recommends (ie Q196507). I think you need Outlook to use Exchange Server
(which is where the GAL is kept) - so I doubt it would work with OE.


| Will this work with Outlook Express?????  The code looks
| OK to me.  Is it using the latest versio of CDO?
|
| Thanks in advance,
| Raney

<snip>



Wed, 27 Jul 2005 21:56:30 GMT  
 Using Outlook Library to extract SMTP addresses
For dealing with Outlook Express address book, you may try the Windows
Address Book (WAB) APIs; please refer to the article:

FILE: Windows Address Book (WAB) Documentation                [mapi]
http://support.microsoft.com/support/kb/articles/q266/3/47.asp

Sincerely,

Alick Ye, MCSD
Product Support Services
Microsoft Corporation
Get Secure! - <www.microsoft.com/security>

This posting is provide "AS IS" with no warranties, and confers no rights.

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

| Newsgroups: microsoft.public.vb.com
| Subject: Re: Using Outlook Library to extract SMTP addresses

|
| The code uses any version of CDO. As you can see, I used the article Alick
| recommends (ie Q196507). I think you need Outlook to use Exchange Server
| (which is where the GAL is kept) - so I doubt it would work with OE.
|


| | Will this work with Outlook Express?????  The code looks
| | OK to me.  Is it using the latest versio of CDO?
| |
| | Thanks in advance,
| | Raney
|
| <snip>
|
|
|
|



Fri, 29 Jul 2005 08:56:03 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Extracting smtp addresses from Outlook

2. Extracting Exchange/Outlook info using Active Messaging 1.1 Object Library

3. smtp email addresses in the Outlook global address list

4. Using VB.Net to extract Outlook 2000 addresses

5. SMTP mail name extract from Outlook

6. Allowing outlook to choose smtp address

7. getting smtp-address from outlook

8. Need a program to extract email addresses from MS Outlook 2000 folders/messages

9. Extract email addresses in an outlook object?

10. How to get SMTP address using CDO 1.21

11. Contact Item, SMTP, EX email address using Redemption?

12. Getting TO and CC SMTP Addresses using CDO?

 

 
Powered by phpBB® Forum Software