fcjoe Posted July 14, 2009 Share Posted July 14, 2009 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 Link to comment Share on other sites More sharing options...
storme Posted July 15, 2009 Share Posted July 15, 2009 Hi JoeI'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 2003Please 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 advanceJohn Morrison Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
IQ9003 Posted July 15, 2009 Share Posted July 15, 2009 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 Link to comment Share on other sites More sharing options...
fcjoe Posted July 15, 2009 Author Share Posted July 15, 2009 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 Link to comment Share on other sites More sharing options...
IQ9003 Posted July 16, 2009 Share Posted July 16, 2009 Hi, In the attached screenshot you can see what I mean. In this example Postvak Iq9003=Postvak gebruiker.postvak_iq.bmp Link to comment Share on other sites More sharing options...
fcjoe Posted July 16, 2009 Author Share Posted July 16, 2009 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.ThanksHi, In the attached screenshot you can see what I mean. In this example Postvak Iq9003=Postvak gebruiker. Link to comment Share on other sites More sharing options...
IQ9003 Posted July 16, 2009 Share Posted July 16, 2009 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 Link to comment Share on other sites More sharing options...
fcjoe Posted July 16, 2009 Author Share Posted July 16, 2009 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....NextThen 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,JoeHi JoeI'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 advanceJohn Morrison Link to comment Share on other sites More sharing options...
fcjoe Posted July 16, 2009 Author Share Posted July 16, 2009 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 Link to comment Share on other sites More sharing options...
IQ9003 Posted July 16, 2009 Share Posted July 16, 2009 There's a good outlook UDF on this forum, it helped me a lot.....at least its a start.OutlookUDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now