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
[1]
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.officedev&lang=en&cr=US
--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
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]
- m...@spam.guard.caspershouse.com
"Alex" <bohe...@gmail.com> wrote in message
news:1184089765.0...@r34g2000hsd.googlegroups.com...
The people who uses my application have already had their Windows and
Outlook properly set up.
On Jul 10, 2:16 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.com> wrote:
> 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]
> - m...@spam.guard.caspershouse.com
>
> "Alex" <bohema...@gmail.com> wrote in message
>
> news:1184089765.0...@r34g2000hsd.googlegroups.com...
>
>
>
> > 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 -
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)?
On Jul 10, 3:03 pm, "Sheng Jiang[MVP]"
<sheng_ji...@hotmail.com.discuss> wrote:
> 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"...
> --
> Sheng Jiang
> Microsoft MVP in VC++"Alex" <bohema...@gmail.com> wrote in message
>
> news:1184089765.0...@r34g2000hsd.googlegroups.com...
>
>
>
> > 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.
>
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]
- m...@spam.guard.caspershouse.com
"Alex" <bohe...@gmail.com> wrote in message
news:1184094704.9...@p39g2000hse.googlegroups.com...
Alex
On Jul 10, 3:17 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.com> wrote:
> 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]
> - m...@spam.guard.caspershouse.com
>
> >> - Show quoted text -- Hide quoted text -
http://pinvoke.net/default.aspx/netapi32/NetUserGetInfo.html
--
Sheng Jiang
Microsoft MVP in VC++
"Alex" <bohe...@gmail.com> wrote in message
news:1184094985....@n2g2000hse.googlegroups.com...
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