VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Get current Outlook user

by Klemens Schmid (9 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

Retrieve the user currently logged on in the existing Microsoft Outlook session.

Assumes
Open a new VB project. Add a button to the form. Add a reference to "Microsoft Outlook ...". Paste the code into the form. Run the project.
Code Returns
Returns the Name property of the recipient object.

Rate Get current Outlook user

Private Sub cmdUser_Click()
'get the user from the current Outlook session
Dim ol As Outlook.Application
Dim ns As NameSpace
Dim oRec As Recipient
Set ol = New Outlook.Application
Set ns = ol.GetNamespace("MAPI")
Call ns.Logon(, , , False)
Set oRec = ns.CurrentUser
MsgBox oRec.Name
End Sub

Download this snippet    Add to My Saved Code

Get current Outlook user Comments

No comments have been posted about Get current Outlook user. Why not be the first to post a comment about Get current Outlook user.

Post your comment

Subject:
Message:
0/1000 characters