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
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