Get e-mail address

U

Ulf Nilsson

Hi,
If I know a name from the global address book, can I get the e-mail address?

If Jon Smith is an entry in the global Address book, can I in some way
retrieve "Smith, Jon" e-mail address? Using GetAddress does not seem to work.

I use Office XP.

// Ulf
 
U

Ulf Nilsson

Thanks for the link,
but I cannot see anything on how to get any e-mail address. Just to create a
contact.

The "<PR_EMAIL_ADDRESS>" does not work.

I'm looking forward to getting more idéas.

// Ulf
 
G

Graham Mayor

You have to use your imagination a bit! There are several examples showing
how to pull data from Outlook which you can modify

Public Sub InsertEmailFromOutlook()
Dim strAddress As String
Dim strEmail As String
strEmail = "<PR_EMAIL_ADDRESS>"
strAddress = Application.GetAddress("", strEmail, _
False, 1, , , True, True)
Selection.TypeText strAddress
End Sub


will pull the e-mail address


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
U

Ulf Nilsson

I am sorry to tell you, but the code does not result in an e-mail address.
It just generates a long string:
"/o=[The name of the company]/ou=[The name of the
company]/cn=Recipients/cn=[A username]"

Sometimes, the "[A username]" is not the username, but something total
different.

How can I use the string to get e-mail addresses?

// Ulf
 
G

Graham Mayor

The macro reads the e-mail field from Outlook and types it at the cursor. If
it doesn't read the e-mail address then the problem is almsot certainly with
the regional setting anomalies between your version of Windows and mine
which may imply different list separator characters. Maybe one of our
Scandinavian contributors will tell you what characters to substitute to
make it work for you.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



Ulf said:
I am sorry to tell you, but the code does not result in an e-mail
address. It just generates a long string:
"/o=[The name of the company]/ou=[The name of the
company]/cn=Recipients/cn=[A username]"

Sometimes, the "[A username]" is not the username, but something total
different.

How can I use the string to get e-mail addresses?

// Ulf

Graham Mayor said:
You have to use your imagination a bit! There are several examples
showing how to pull data from Outlook which you can modify

Public Sub InsertEmailFromOutlook()
Dim strAddress As String
Dim strEmail As String
strEmail = "<PR_EMAIL_ADDRESS>"
strAddress = Application.GetAddress("", strEmail, _
False, 1, , , True, True)
Selection.TypeText strAddress
End Sub


will pull the e-mail address


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
U

Ulf Nilsson

Thank you Graham!
You helped me stop thinking in terms of "GetAddress". I solved it by using
GetObject and LDAP. The tool ADSIEdit from Microsoft is a great tool to see
the exact path to users.

The code:
Dim objSysInfo, adsUser
Set objSysInfo = CreateObject("ADSystemInfo")
Set adsUser = GetObject("LDAP://CN=Nilsson\,
Ulf,OU=Users,OU=Bor,OU=AV,DC=av,DC=se")
MsgBox adsUser.mail

Useful links:
http://www.rlmueller.net/LDAP_Binding.htm
http://www.tek-tips.com/viewthread.cfm?qid=920511&page=5
http://www.msexchange.org/articles/Scripting-Exchange-VBScript-ADSI-Part1.html

// Ulf

Graham Mayor said:
The macro reads the e-mail field from Outlook and types it at the cursor. If
it doesn't read the e-mail address then the problem is almsot certainly with
the regional setting anomalies between your version of Windows and mine
which may imply different list separator characters. Maybe one of our
Scandinavian contributors will tell you what characters to substitute to
make it work for you.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



Ulf said:
I am sorry to tell you, but the code does not result in an e-mail
address. It just generates a long string:
"/o=[The name of the company]/ou=[The name of the
company]/cn=Recipients/cn=[A username]"

Sometimes, the "[A username]" is not the username, but something total
different.

How can I use the string to get e-mail addresses?

// Ulf

Graham Mayor said:
You have to use your imagination a bit! There are several examples
showing how to pull data from Outlook which you can modify

Public Sub InsertEmailFromOutlook()
Dim strAddress As String
Dim strEmail As String
strEmail = "<PR_EMAIL_ADDRESS>"
strAddress = Application.GetAddress("", strEmail, _
False, 1, , , True, True)
Selection.TypeText strAddress
End Sub


will pull the e-mail address


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>




Ulf Nilsson wrote:
Thanks for the link,
but I cannot see anything on how to get any e-mail address. Just to
create a contact.

The "<PR_EMAIL_ADDRESS>" does not work.

I'm looking forward to getting more idéas.

// Ulf

:

See the method at http://www.gmayor.com/Macrobutton.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Ulf Nilsson wrote:
Hi,
If I know a name from the global address book, can I get the
e-mail address?

If Jon Smith is an entry in the global Address book, can I in some
way retrieve "Smith, Jon" e-mail address? Using GetAddress does
not seem to work.

I use Office XP.

// Ulf
 

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