473,851 Members | 2,297 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading windows user's email address

Hi

Outlook 2003 connected with exchange server.

A user is logged in to the client pc. Is it possible to programmaticall y get
the user's email address that is set on the 'Email Addresses' tab of the
exchange server?

Thanks

Regards

Jun 27 '08 #1
4 1843
On May 30, 1:28*pm, "John" <i...@nospam.in fovis.co.ukwrot e:
Hi

Outlook 2003 connected with exchange server.

A user is logged in to the client pc. Is it possible to programmaticall y get
the user's email address that is set on the 'Email Addresses' tab of the
exchange server?

Thanks

Regards
Add a reference for
Imports System.Net.Mail

Then:
Dim mail As New MailMessage()
mail.To = "me@mycompany.c om"
mail.From = "yo*@yourcompan y.com"
mail.Subject = "this is a test email."
mail.Body = "this is my test email body."
Dim attachment As New MailAttachment( Server.MapPath( "test.txt") )
'create the attachment
mail.Attachment s.Add(attachmen t) 'add the attachment
SmtpMail.SmtpSe rver = "localhost" 'your real server goes here
SmtpMail.Send(m ail)

You can also do a search on reading the Active Directory, it was very
helpful for me.

regards,

Big B
Jun 27 '08 #2
On May 30, 1:28*pm, "John" <i...@nospam.in fovis.co.ukwrot e:
Hi

Outlook 2003 connected with exchange server.

A user is logged in to the client pc. Is it possible to programmaticall y get
the user's email address that is set on the 'Email Addresses' tab of the
exchange server?

Thanks

Regards
Here is the code for searching the Active Directory I use:

Dim oroot As DirectoryServic es.DirectoryEnt ry = New
DirectoryServic es.DirectoryEnt ry("LDAP://ATOMIC")
Dim osearcher As DirectoryServic es.DirectorySea rcher = New
DirectoryServic es.DirectorySea rcher(oroot)

osearcher.Searc hScope = SearchScope.Sub tree
Dim oResults As SearchResultCol lection
Dim oResult As SearchResult
osearcher.Filte r = "(&(objectCateg ory=user)
(objectClass=us er)(sn=" & mLast & "))"

osearcher.Prope rtiesToLoad.Add ("cn")

osearcher.Prope rtiesToLoad.Add ("SAMAccountNam e") 'Users login name

osearcher.Prope rtiesToLoad.Add ("givenName" ) 'Users first name

osearcher.Prope rtiesToLoad.Add ("sn") 'Users last name

osearcher.Prope rtiesToLoad.Add ("mailNickname" ) 'Users Alias

osearcher.Prope rtiesToLoad.Add ("mail") 'Users email

oResults = osearcher.FindA ll

For Each oResult In oResults
If oResult.Propert ies("sn")(0) = mLast And
oResult.Propert ies("givenName" )(0) = mFirst Then
If Not oResult.Propert ies("mail")(0) =
"" Then
mEmail = oResult.Propert ies("mail")
(0)
mCCHDLogin =
oResult.Propert ies("samAccount Name")(0)
Exit For
End If
End If
Next
Jun 27 '08 #3
On May 30, 1:28*pm, "John" <i...@nospam.in fovis.co.ukwrot e:
Hi

Outlook 2003 connected with exchange server.

A user is logged in to the client pc. Is it possible to programmaticall y get
the user's email address that is set on the 'Email Addresses' tab of the
exchange server?

Thanks

Regards
Not sure if this posted :

Here is the code for searching the Activr Directory:

Dim sItem As String =
"CN=ATOMIC,CN=S ervers,CN=CCHD, CN=Sites,CN=Con figuration,DC=C CHD,DC=ORG"

Dim oroot As DirectoryServic es.DirectoryEnt ry = New
DirectoryServic es.DirectoryEnt ry("LDAP://ATOMIC")
Dim osearcher As DirectoryServic es.DirectorySea rcher = New
DirectoryServic es.DirectorySea rcher(oroot)

osearcher.Searc hScope = SearchScope.Sub tree
Dim oResults As SearchResultCol lection
Dim oResult As SearchResult
osearcher.Filte r = "(&(objectCateg ory=user)
(objectClass=us er)(sn=" & mLast & "))"

osearcher.Prope rtiesToLoad.Add ("cn")

osearcher.Prope rtiesToLoad.Add ("SAMAccountNam e") 'Users login name

osearcher.Prope rtiesToLoad.Add ("givenName" ) 'Users first name

osearcher.Prope rtiesToLoad.Add ("sn") 'Users last name

osearcher.Prope rtiesToLoad.Add ("mailNickname" ) 'Users Alias

osearcher.Prope rtiesToLoad.Add ("mail") 'Users email

oResults = osearcher.FindA ll

'oResult.GetDir ectoryEntry().P roperties("sn") .Value
For Each oResult In oResults
If oResult.Propert ies("sn")(0) = mLast And
oResult.Propert ies("givenName" )(0) = mFirst Then
If Not oResult.Propert ies("mail")(0) =
"" Then
mEmail = oResult.Propert ies("mail")
(0)
mLogin =
oResult.Propert ies("samAccount Name")(0)
Exit For
End If
End If
Next
Jun 27 '08 #4
Hi

Many thanks. This is very useful.

Regards
<bw*****@cox.ne twrote in message
news:c3******** *************** ***********@56g 2000hsm.googleg roups.com...
On May 30, 1:28 pm, "John" <i...@nospam.in fovis.co.ukwrot e:
Hi

Outlook 2003 connected with exchange server.

A user is logged in to the client pc. Is it possible to programmaticall y
get
the user's email address that is set on the 'Email Addresses' tab of the
exchange server?

Thanks

Regards
Not sure if this posted :

Here is the code for searching the Activr Directory:

Dim sItem As String =
"CN=ATOMIC,CN=S ervers,CN=CCHD, CN=Sites,CN=Con figuration,DC=C CHD,DC=ORG"

Dim oroot As DirectoryServic es.DirectoryEnt ry = New
DirectoryServic es.DirectoryEnt ry("LDAP://ATOMIC")
Dim osearcher As DirectoryServic es.DirectorySea rcher = New
DirectoryServic es.DirectorySea rcher(oroot)

osearcher.Searc hScope = SearchScope.Sub tree
Dim oResults As SearchResultCol lection
Dim oResult As SearchResult
osearcher.Filte r = "(&(objectCateg ory=user)
(objectClass=us er)(sn=" & mLast & "))"

osearcher.Prope rtiesToLoad.Add ("cn")

osearcher.Prope rtiesToLoad.Add ("SAMAccountNam e") 'Users login name

osearcher.Prope rtiesToLoad.Add ("givenName" ) 'Users first name

osearcher.Prope rtiesToLoad.Add ("sn") 'Users last name

osearcher.Prope rtiesToLoad.Add ("mailNickname" ) 'Users Alias

osearcher.Prope rtiesToLoad.Add ("mail") 'Users email

oResults = osearcher.FindA ll

'oResult.GetDir ectoryEntry().P roperties("sn") .Value
For Each oResult In oResults
If oResult.Propert ies("sn")(0) = mLast And
oResult.Propert ies("givenName" )(0) = mFirst Then
If Not oResult.Propert ies("mail")(0) =
"" Then
mEmail = oResult.Propert ies("mail")
(0)
mLogin =
oResult.Propert ies("samAccount Name")(0)
Exit For
End If
End If
Next
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1874
by: RA | last post by:
Hi I have a contact us button that when the user clicks it I want it to open the user default mail form put the To information with the name whom this email will be sent to and the rest is up to the user to put the subject and message and then he can send it. Basicaly I Just want to open an email with the 'To' field already set. How do I do it if I am using c# windows forms? Thanks
3
7492
by: Chris Paul | last post by:
I'm having trouble with PHP & PostgreSQL/OpenLDAP/Apache on Windows. I've set this up countless times on BSD (piece of cake) but I'm trying to do this on Windows now so that my developer can work on her local machine. Everything looks pretty good. OpenLDAP/cygwin works great. PostgreSQL works great. Apache runs. PHP runs. But when I try to connect to my PostgreSQL server using PHPPgAdmin, I
44
9471
by: Viken Karaguesian | last post by:
Hello all, On occasion I want to open hyperlinks (images, etc.) in a new window. In the past, I've used target="_blank" to open the link in a new window. However, using the "target" attribute causes my pages to fail validation (strict doctype). The validator says "There is no attribute 'target'.." So...how do I open a link in a new window, without Javscript, and pass strict validation?
5
3741
by: Dennis Fazekas | last post by:
Greetings, I am creating a web form which will all the user to add an unlimited number of email addresses. Basically I have 3 buttons, "Add Another Email", "-" to remove, and a "Save" button. When the user clicks the "Add another email" it will call a client side JavaScript function, add_email, which will dynamically add a new set of controls to the webpage using the innerHTML method. It appears to work perfectly fine in the browser. The...
4
2395
by: News | last post by:
Hi Everyone, The attached code creates client connections to websphere queue managers and then processes an inquiry against them. The program functions when it gets options from the command line. It also works when pulling the options from a file.
16
4204
by: bloggsfred00 | last post by:
I need to read incoming bytes on a COM port but I do not want to have the script hang if there is nothing to read. Is there any way to have PHP interrogate a COM port buffer to see if there is any content before reading it? Any other method to achieve the result would also be welcome. Cheers,
3
2465
by: Chris Noble | last post by:
I need to be able to read and add to the collection of email addesses for an Active Directory User with a mailbox. I assume that this is a collection object. However I can't find any help on which technology to use. I can create and access the properties for a user using System.DirectoryServices.DirectoryEntry and then create a mailbox using CDOEXM.IMailboxStore which adds an e-mail address automatically. There is an email property on...
5
9156
by: Max2006 | last post by:
Hi, I am trying to limit my wcf service endpoint to response to only given windows user or group. How can I do that? Is there any way to configure that in the .config file? Thank you, Max
0
9895
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9744
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11011
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10725
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7072
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5931
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4142
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3178
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.