Current User capture

R

RJ

I am trying to capture the userid of an outlook user with
the following code:

'Get data from Session.CurrentUser.
Dim cdoSession 'As MAPI.Session
Dim cdoAddrEntry 'As AddressEntry
Dim strUsername 'as string

'Define them explicitly or use their value.
dim cdoPR_Account
dim cdoPR_EntryID
Dim vbCRLF

cdoPR_Account = &h3a00001e
cdoPR_EntryID = &h0fff0102
vbCRLF = chr(13) & chr(10)

on error resume next

'Start the CDO code to find a match.
Set cdoSession = CreateObject("Mapi.session")
cdoSession.Logon ,,false,false,0
if err.number <> 0 then msgbox "ERROR in logon: " &
err.number & vbCRLF & err.description

'Get the AddressEntry of the recipient/current user.
Set cdoAddrEntry = cdoSession.CurrentUser
if err.number <> 0 then msgbox "ERROR getting
AddressEntry: " & err.number & vbCRLF & err.description

'Get properties.
strUsername = cdoAddrEntry.fields(cdoPR_Account)

objUsername.value = strUsername

'Explicitly release objects.
cdoSession.logoff
Set cdoAddrEntry = Nothing
Set cdoSession = Nothing

When I test the code on my computer it works just fine,
however, when I go over to a colleague's computer and try
it on there, I get the error messages in the code above.

The same version of OL2K is used so I don't see a problem
there. Can it be that only one login can be used at a
time? Please help (if you can?).

Thanks
 
P

Patricia Cardoza - [MVP Outlook]

What error message? CDO isn't installed by default in all versions of
Outlook so it might be that your user's computer doesn't have it installed.
Run Add/Remove Programs and select Outlook. Then you should be able to add
CDO.

--
Patricia Cardoza
Outlook MVP

Author, Special Edition Using Microsoft Outlook 2003

***Please post all replies to the newsgroups***
 

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