Get the Name and Phone Number of the Current Windows User in a .NET Application

A

Alex

Get the Name and Phone Number of the Current Windows User in a .NET
Application

I am writing a simple .NET (C#) application. It needs to "automatic"
get the Name (last, first) and phone number of the current Windows
user.

I guess the name can be retrieved from the environment -- After I
click the Start button of Windows, my name is on the very first line
of the popup menu. So, this information is provided by the Windows
environment.

My question is how I get this environment information in a C#
application.

I also need to get the phone number of the current Windows user. I
can safely assume:
(1) Outlook is installed.
(2) The phone number of the current Windows user is in the Outlook
profile.

Is there a way to obtain the phone number of the current Windows
user? We canNOT assume that Outlook is running when my application is
running.

Your input is highly appreciated.

Thanks.

Alex
 
N

Nicholas Paldino [.NET/C# MVP]

Alex,

This is going to be near impossible. First, the full name of a user is
not always stored with the user account. You can get that from the Outlook
profile most likely (or any Office app, through interop), but the phone
number is by no means guaranteed.
 
S

Sheng Jiang[MVP]

You can get the current user name by using Environment.UserName
The logon name may differ from the legal name of the user. For example, many
users log on as "Administrator"...
 
A

Alex

Thanks, Nick for the input.

The people who uses my application have already had their Windows and
Outlook properly set up.

Alex,

This is going to be near impossible. First, the full name of a user is
not always stored with the user account. You can get that from the Outlook
profile most likely (or any Office app, through interop), but the phone
number is by no means guaranteed.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




Get the Name and Phone Number of the Current Windows User in a .NET
Application
I am writing a simple .NET (C#) application. It needs to "automatic"
get the Name (last, first) and phone number of the current Windows
user.
I guess the name can be retrieved from the environment -- After I
click the Start button of Windows, my name is on the very first line
of the popup menu. So, this information is provided by the Windows
environment.
My question is how I get this environment information in a C#
application.
I also need to get the phone number of the current Windows user. I
can safely assume:
(1) Outlook is installed.
(2) The phone number of the current Windows user is in the Outlook
profile.
Is there a way to obtain the phone number of the current Windows
user? We canNOT assume that Outlook is running when my application is
running.
Your input is highly appreciated.

Alex- Hide quoted text -

- Show quoted text -
 
A

Alex

Sheng,

Thanks for the input. Let's say my logon name is AlexLogOnName, but
when I click the Start Button of my Windows, my name -- LastName, Alex
-- is shown in the popup menu. I guess my Windows is properly set up
with user's logon name and user's real name (Last, first). Any input
on how windows differentiate logon and real name (last, first)?
 
N

Nicholas Paldino [.NET/C# MVP]

Alex,

If that's the case, then you should be able to access the information in
Outlook through the Outlook object model (using the primary interop
assemblies for Outlook).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Alex said:
Thanks, Nick for the input.

The people who uses my application have already had their Windows and
Outlook properly set up.

Alex,

This is going to be near impossible. First, the full name of a user
is
not always stored with the user account. You can get that from the
Outlook
profile most likely (or any Office app, through interop), but the phone
number is by no means guaranteed.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




Get the Name and Phone Number of the Current Windows User in a .NET
Application
I am writing a simple .NET (C#) application. It needs to "automatic"
get the Name (last, first) and phone number of the current Windows
user.
I guess the name can be retrieved from the environment -- After I
click the Start button of Windows, my name is on the very first line
of the popup menu. So, this information is provided by the Windows
environment.
My question is how I get this environment information in a C#
application.
I also need to get the phone number of the current Windows user. I
can safely assume:
(1) Outlook is installed.
(2) The phone number of the current Windows user is in the Outlook
profile.
Is there a way to obtain the phone number of the current Windows
user? We canNOT assume that Outlook is running when my application is
running.
Your input is highly appreciated.

Alex- Hide quoted text -

- Show quoted text -
 
A

Alex

Thanks. Nick ...

Alex

Alex,

If that's the case, then you should be able to access the information in
Outlook through the Outlook object model (using the primary interop
assemblies for Outlook).

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




Thanks, Nick for the input.
The people who uses my application have already had their Windows and
Outlook properly set up.
Alex,
This is going to be near impossible. First, the full name of a user
is
not always stored with the user account. You can get that from the
Outlook
profile most likely (or any Office app, through interop), but the phone
number is by no means guaranteed.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Get the Name and Phone Number of the Current Windows User in a .NET
Application
I am writing a simple .NET (C#) application. It needs to "automatic"
get the Name (last, first) and phone number of the current Windows
user.
I guess the name can be retrieved from the environment -- After I
click the Start button of Windows, my name is on the very first line
of the popup menu. So, this information is provided by the Windows
environment.
My question is how I get this environment information in a C#
application.
I also need to get the phone number of the current Windows user. I
can safely assume:
(1) Outlook is installed.
(2) The phone number of the current Windows user is in the Outlook
profile.
Is there a way to obtain the phone number of the current Windows
user? We canNOT assume that Outlook is running when my application is
running.
Your input is highly appreciated.
Thanks.
Alex- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
 
A

Alex

First, thank you for all your help

Some update:

1. I can easily get users Windows login name which is the SAME as
Outlook email Alias, by using Environment.UserName

2. After add Outlook Object references, I can do something like:

Outlook._Application olApp = new
Outlook.ApplicationClass();
Outlook.NameSpace oNS = olApp.GetNamespace("MAPI");
Outlook.AddressList oAL = oNS.AddressLists["Global Address
List"];
Outlook.AddressEntries oAEs = oAL.AddressEntries;

In this way, I can get the AddressEntries. My question is can I
search the AddressEntries for the user login name I found by using
Environment.UserName? I did not find a method for search/find
 

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