Search code examples
vb.netoutlook

How to get Outlook.NameSpace.CurrentUser value?


Dim app As Microsoft.Office.Interop.Outlook.Application = GetApplicationObject()
Dim ns As Microsoft.Office.Interop.Outlook._NameSpace = Nothing
Dim inboxFolder As Microsoft.Office.Interop.Outlook.MAPIFolder = Nothing
ns = app.GetNamespace("MAPI")

ns.CurrentUser = Username

I'm trying to get .CurrentUser value to Username data item.

I get this compiler error:

Property 'CurrentUser' is 'ReadOnly'

How can I get it`s value? Tried to use Get Return.


Solution

  • Change your code to

    Username = ns.CurrentUser.Name