BigDaddyO Posted April 13, 2007 Share Posted April 13, 2007 I have been looking for probably 2 hours not to find something that I thought would be easy.I want to find out if Outlook is installed, If so is it configured, If it's configured what UserName is it configured to use.Why is this so hard!!!Finding if outlook is installed was easy. Just call the Outlook Com object and ensure it was created. It's after that where I'm stuck.MSDN Link to the Outlook UserName infomy failing attempt so far. I have been going round and round for too long...$oOutlook = ObjCreate("Outlook.Application") if IsObj($oOutlook) Then $user = $oOutlook.Application.GetNameSpace("MAPI");.CurrentUser $id1 = $user.Account.UserName MsgBox(0, "UserName", $id1);$oOutlook.Account.UserName) EndIfThanks for any help you can provide.Mike Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted April 13, 2007 Moderators Share Posted April 13, 2007 Try this: #include <IE.au3> _IEErrorHandlerRegister() $oOutlook = ObjCreate("Outlook.Application") If Not IsObj($oOutlook) Then MsgBox(0, "", "Unable to create object!") Exit EndIf $oNameSpace = $oOutlook.GetNameSpace ("MAPI") $oAccounts = $oNameSpace.Accounts $iCount = $oAccounts.Count $i = 1 $sProp = "" For $oAccount In $oAccounts With $oAccount $sProp &= "Account #: " & $i & @CR $sProp &= "Account Type: " & .AccountType & @CR $sProp &= "Class: " & .Class & @CR $sProp &= "Display Name: " & .DisplayName & @CR $sProp &= "SMTP Address: " & .SmtpAddress & @CR $sProp &= "User Name: " & .UserName If $i <> $iCount Then $sProp &= @CR & @CR EndWith $i += 1 Next ConsoleWrite($sProp & @CR) Link to comment Share on other sites More sharing options...
BigDaddyO Posted April 13, 2007 Author Share Posted April 13, 2007 (edited) Big_Daddy,Thanks for the attempt but I just get this in the scite Consoleedit: updated the cosole data: I origionally had this pasted at the bottom of a test script so the line numbers were off.--> COM Error Encountered in Testing.au3 ----> $IEComErrorScriptline = 11 ----> $IEComErrorNumberHex = 80020006 ----> $IEComErrorNumber = -2147352570 ----> $IEComErrorWinDescription = Unknown name. ----> $IEComErrorDescription = ----> $IEComErrorSource = ----> $IEComErrorHelpFile = ----> $IEComErrorHelpContext = ----> $IEComErrorLastDllError = 0 --> COM Error Encountered in Testing.au3 ----> $IEComErrorScriptline = 12 ----> $IEComErrorNumberHex = 000000A9 ----> $IEComErrorNumber = 169 ----> $IEComErrorWinDescription = Variable must be of type 'Object'. ----> $IEComErrorDescription = ----> $IEComErrorSource = ----> $IEComErrorHelpFile = ----> $IEComErrorHelpContext = ----> $IEComErrorLastDllError = 0 --> COM Error Encountered in Testing.au3 ----> $IEComErrorScriptline = 15 ----> $IEComErrorNumberHex = 000000A9 ----> $IEComErrorNumber = 169 ----> $IEComErrorWinDescription = Variable is not of type 'Object'. ----> $IEComErrorDescription = ----> $IEComErrorSource = ----> $IEComErrorHelpFile = ----> $IEComErrorHelpContext = ----> $IEComErrorLastDllError = 0I have been working on this more this morning and I finally got some code that will retrieve the UserName but it throws an Outlook security box, so sadly I can't use it.;Works but prompts the user with a security message $oOutlook = ObjCreate("Outlook.Application") $oSession = ObjCreate("Redemption.RDOSession") $oAddress = $oOutlook.GetNamespace("MAPI").CurrentUser.Name MsgBox(0, "", $oAddress) Edited April 13, 2007 by MikeOsdx Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted April 13, 2007 Moderators Share Posted April 13, 2007 Works perfectly for me, I get something like this. Account #: 1 Account Type: 0 Class: 105 Display Name: Microsoft Exchange Server SMTP Address: someone@somewhere.com User Name: UserName Account #: 2 Account Type: 2 Class: 105 Display Name: someone@somewhere.com SMTP Address: someone@somewhere.com User Name: UserName Account #: 3 Account Type: 2 Class: 105 Display Name: someone@somewhere.com SMTP Address: someone@somewhere.com User Name: UserName Account #: 4 Account Type: 2 Class: 105 Display Name: someone@somewhere.com SMTP Address: someone@somewhere.com User Name: UserName What version of Outlook are you testing on? Link to comment Share on other sites More sharing options...
BigDaddyO Posted April 13, 2007 Author Share Posted April 13, 2007 (edited) Works perfectly for me, I get something like this.What version of Outlook are you testing on?I am using Outlook 2003 with Office 2007, but the Office 2007 shouldn't make a difference.edit: and I am connected directly to an Exchange server, not POP3Mike Edited April 13, 2007 by MikeOsdx Link to comment Share on other sites More sharing options...
Zedna Posted April 13, 2007 Share Posted April 13, 2007 I have tha same errors like MikeOsdx I have Outlook 2003 (with whole Office) on WIN XP sp2. Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted April 13, 2007 Moderators Share Posted April 13, 2007 Hmmm.... I'm using Outlook 2007 so maybe that is the difference. I'll see if I can figure out the difference when I get home, I have Outlook 2003 installed on an old machine there. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted April 13, 2007 Moderators Share Posted April 13, 2007 See if this works for you. #include <IE.au3> _IEErrorHandlerRegister() $oOutlook = ObjCreate("Outlook.Application") If Not IsObj($oOutlook) Then MsgBox(0, "", "Unable to create object!") Exit EndIf $oNameSpace = $oOutlook.GetNameSpace ("MAPI") $oUser = $oNameSpace.CurrentUser If Not IsObj($oUser) Then MsgBox(0, "Error", "There is no current user.") Exit EndIf ConsoleWrite($oUser.Name & @CR) Link to comment Share on other sites More sharing options...
BigDaddyO Posted April 14, 2007 Author Share Posted April 14, 2007 (edited) See if this works for you. #include <IE.au3> _IEErrorHandlerRegister() $oOutlook = ObjCreate("Outlook.Application") If Not IsObj($oOutlook) Then MsgBox(0, "", "Unable to create object!") Exit EndIf $oNameSpace = $oOutlook.GetNameSpace ("MAPI") $oUser = $oNameSpace.CurrentUser If Not IsObj($oUser) Then MsgBox(0, "Error", "There is no current user.") Exit EndIf ConsoleWrite($oUser.Name & @CR) That code pulls the user name but like the sample I put in post#3, I get a security warning that the user must hit OK to. So sadly I can't really use it. I think I am going to send an e-mail to the Scripting Guys on Microsofts Website, then convert it to AutoIT of course. It's just stupid how difficult this is. Thanks, Mike Edited April 14, 2007 by MikeOsdx 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