I've got the following code behind the 'Open' form event
and it's essentially for getting the users login id only.
I copied this code from another application and perhaps I
have too much? Can you help identify the unnecessary
code? I.e. not related to just getting the userid?
'This section of code is to get a UserId
'Get data from Session.CurrentUser.
Dim cdoSession 'As MAPI.Session
Dim cdoAddrEntry 'As AddressEntry
Dim strData 'as string
Dim strUserid '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 'Use the existing
Outlook session.
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.
strUserid = cdoAddrEntry.fields(cdoPR_Account)
objUserid.value = strUserid
objAuditUserid.value = strUserid
objVacUserid.value = strUserid
objTrdUserid.value = strUserid
objTrdAuditUserid.value = strUserid
'Explicitly release objects.
cdoSession.logoff
'Set cdoAddrEntry = Nothing
Set cdoSession = Nothing
-----Original Message-----
What code do you have behind the form's Open or Read
events? In the meantime, see
http://www.slipstick.com/outlook/esecup.htm#autosec
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at
http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
"Rob" <
[email protected]> wrote in
message news:
[email protected]...