Home
Forums
New posts
Search forums
Articles
Latest reviews
Search resources
Members
Current visitors
Newsgroups
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Programming
Get Outlook Address Book info
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Guest, post: 2925146"] Here is what I use to Get E-mail addresses. You can modify it to get the other address info you need. You will need to reference the Microsoft CDO Library. Option Explicit Const CdoPR_EMS_AB_PROXY_ADDRESSES = &H800F101E Const g_strMAPILogOn As String = "MS Exchange Settings" Const g_strAddressList As String = "Global Address List" Const g_strEMailAddressIdentifier As String = "SMTP" Private Sub Test() MsgBox GetEMailAddress("Jim Thomlinson") End Sub Public Function GetEMailAddress(ByVal strName As String) As String Dim objSession As MAPI.Session Dim objField As MAPI.Field Dim MyAddressList As MAPI.AddressList Dim MyAddressEntries As MAPI.AddressEntries Dim MyEntry As MAPI.AddressEntry Dim SomeEntry As MAPI.AddressEntry Dim MyRecipient As MAPI.Recipient Dim v As Variant Dim strReturnValue As String 'Initialize Local Variables strReturnValue = "No Address Found" 'Retrun Value if not found ' Create Session object and Logon. Set objSession = CreateObject("MAPI.Session") objSession.Logon (g_strMAPILogOn) 'Create the Address list from the Global Address List Set MyAddressList = objSession.AddressLists(g_strAddressList) If MyAddressList Is Nothing Then MsgBox g_strAddressList & " Unavailable!", vbCritical, "Critical Error" Exit Function End If 'Initialize MyAddressEntires with the entries in the Address List Set MyAddressEntries = MyAddressList.AddressEntries 'Traverse through the entries searching for a match For Each SomeEntry In MyAddressEntries Set MyEntry = SomeEntry If Trim(UCase(strName)) = Trim(UCase(MyEntry.Name)) Then Set objField = MyEntry.Fields(CdoPR_EMS_AB_PROXY_ADDRESSES) ' 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 If InStr(1, UCase(v), g_strEMailAddressIdentifier) Then strReturnValue = Mid(v, 6, 256) Exit For End If Next 'Next Field Value Exit For End If Next 'Next Address Entry 'Return Function Value GetEMailAddress = strReturnValue 'Housekeeping Set objField = Nothing Set MyAddressList = Nothing Set MyAddressEntries = Nothing Set MyEntry = Nothing Set MyRecipient = Nothing objSession.Logoff Set objSession = Nothing End Function [/QUOTE]
Verification
Post reply
Home
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Programming
Get Outlook Address Book info
Top