How can I pull current user info into a custom outlook form?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating a custom form in Outlook and would like to pull in the current
Users Manager's name. Any suggestions on where I go to find some code to
accomplish that?
 
Jenn said:
I am creating a custom form in Outlook and would like to pull in the
current
Users Manager's name. Any suggestions on where I go to find some code to
accomplish that?


If by that you mean the user that's currently logged in to Windows, this
will do it in VB6:


Private Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA"
(ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As
Long

Function GetLoggedInUser() As String

Dim UserName As String, Ln As Long
UserName = String$(1024, 0)
Ln = 1023
WNetGetUser vbNullString, UserName, Ln
GetLoggedInUser = UserName

End Function



-Mark
 
Ken Slovak - said:
Form code (VBScript) can't use Win32 API functions.

In that case:

Set WshNetwork = CreateObject("Wscript.Network")
UserName = WshNetwork.UserName


-Mark



Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


Mark J. McGinty said:
If by that you mean the user that's currently logged in to Windows, this
will do it in VB6:


Private Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA"
(ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long)
As Long

Function GetLoggedInUser() As String

Dim UserName As String, Ln As Long
UserName = String$(1024, 0)
Ln = 1023
WNetGetUser vbNullString, UserName, Ln
GetLoggedInUser = UserName

End Function



-Mark
 
That would work.

Unless of course something like a script stopper prevents instantiating
scripting objects.
 
Back
Top