Sign in to follow this  
Followers 0
fcjoe

Lookup email address

10 posts in this topic

Hello,

Does anyone know of a way to lookup the email address from a user's machine setup with Outlook 2003/7? There is a way to look it up in the registry for 2003, but the registry key does not exist in 2007. I guess Microsoft felt like getting rid of it. I have a script that would send an email to a specific account if there were any errors. The from address would be the user's email address. Works fine when all we had were machines with Outlook 2003, but we've been upgrading to 2007 and now I have no way of getting the user's email address.

Thanks,

Joe

Share this post


Link to post
Share on other sites



Hi Joe

I'm doing something similar for my customers (Home) but they use every kind of email client :) so it makes it hard to automate the facility. I've been asking them their email on installation then storing it in an ini file. Hardly a great solution and breaks when they chance their emial address.

Your solution sounds better (except I'll have to program all client email programs). ;)

There is a way to look it up in the registry for 2003

Please post the information it will be a good start for me and maybe others. :)

Also if you have any information about other Email clients it'd be great if you posted them.

Thanks in advance

John Morrison

Share this post


Link to post
Share on other sites

Hello,

I'm not sure this helps you (I'm not exactly sure what you meant) But perhaps this could help you. It retreives the currentusers mailadress (the user must be logged in)

In this example I used a hardcoded mailbox, but maybe it can be done with defaultfolder.

$oOApp = ObjCreate("Outlook.Application")
$myNamespace =$oOApp.GetNamespace("MAPI")
$myfolder=$myNamespace.Folders("Postvak Gebruiker").folders.session.currentuser.address

Share this post


Link to post
Share on other sites

Hello,

I tried the code and got an error. What should I put in place of "Postvak Gebruiker". I tried using my full name and my username but both returned the same error. The error I got was 'The requested action with this object has failed' and it points to right after the ')' with the name?

Thanks,

Joe

Hello,

I'm not sure this helps you (I'm not exactly sure what you meant) But perhaps this could help you. It retreives the currentusers mailadress (the user must be logged in)

In this example I used a hardcoded mailbox, but maybe it can be done with defaultfolder.

$oOApp = ObjCreate("Outlook.Application")
$myNamespace =$oOApp.GetNamespace("MAPI")
$myfolder=$myNamespace.Folders("Postvak Gebruiker").folders.session.currentuser.address

Share this post


Link to post
Share on other sites

Hi,

In the attached screenshot you can see what I mean. In this example Postvak Iq9003=Postvak gebruiker.

postvak_iq.bmp

Share this post


Link to post
Share on other sites

Thanks, it worked when I typed it in for my mailbox, but it doesn't really help since you would have to know what to type in. But this might come in handy one day.

Thanks

Hi,

In the attached screenshot you can see what I mean. In this example Postvak Iq9003=Postvak gebruiker.

Share this post


Link to post
Share on other sites

Well, perhaps this could be of use to you (It gets the currentusers adress, so you don't have to specify the account.

$oOApp = ObjCreate("Outlook.Application")
$myNamespace =$oOApp.GetNamespace("MAPI")
$myfolder=$myNamespace.CurrentUser.Address

Share this post


Link to post
Share on other sites

Storme,

I found it in the registry for Outlook 2003 and Outlook 2007, both in different locations.

"HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"

This will list all mail profiles for both versions of Outlook. Use a loop with regenumkey to go through each one.

$rkWMSProfile = "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"

For $i= 1 to 10

$Profile = RegEnumKey($rkWMSProfile, $i)

...insert code here....

Next

Then for each profile you go into the following subkeys depending on the version of Outlook you have.

For 2003 (Might also work for 2000 but I don't have that anymore so I can't confirm):

The SMTP address is in "\0a0d020000000000c000000000000046\001e0394"

Regread will return it as a string.

For 2007:

"\13dbb0c8aa05101a9bb000aa002fc45a\001f6641"

This is stored in HEX and for some reason new version of Autoit now returns that with "0x" in the front. So you will want to trim the first two characters then use _HexToString command to convert it to a string. The address is stored as "SMTP:JohnDoe@acme.com" so you will want to trim off 'SMTP:' as well. You could trim it off when it's still in HEX format but I haven't had time to clean up my code yet.

There are other keys that list more information like the Full name and AD path info, take a look if you're interested.

As for other email clients like Lotus Notes or others I wouldn't know. We used to use Lotus Notes in my company, I remember there being an ini file somewhere that listed a lot of information.

Hope this helps,

Joe

Hi Joe

I'm doing something similar for my customers (Home) but they use every kind of email client :) so it makes it hard to automate the facility. I've been asking them their email on installation then storing it in an ini file. Hardly a great solution and breaks when they chance their emial address.

Your solution sounds better (except I'll have to program all client email programs). ;)

Please post the information it will be a good start for me and maybe others. :)

Also if you have any information about other Email clients it'd be great if you posted them.

Thanks in advance

John Morrison

Share this post


Link to post
Share on other sites

That works pretty good, and a lot easier than going through the registry like I was doing. Can you point me to a list of other info I can get from the Outlook.Application object. I'm assuming I can get more than just CurrentUser.Address. I don't work too much with COM Objects, only starting to get my feet wet.

Thanks,

Joe

Well, perhaps this could be of use to you (It gets the currentusers adress, so you don't have to specify the account.

$oOApp = ObjCreate("Outlook.Application")
$myNamespace =$oOApp.GetNamespace("MAPI")
$myfolder=$myNamespace.CurrentUser.Address

Share this post


Link to post
Share on other sites

There's a good outlook UDF on this forum, it helped me a lot.

....at least its a start.

OutlookUDF

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0