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

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

Mark J. McGinty

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
 
M

Mark J. McGinty

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
 
K

Ken Slovak - [MVP - Outlook]

That would work.

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

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