Email Address of the Current User
Hi,
How can I get the Email Address of the Login User from Outlook.
The Me.Session.CurrentUser.address return a lot of additional data, what I want is just the Email Address.
Thanks.
Andy Ho
Hi,
How can I get the Email Address of the Login User from Outlook.
The Me.Session.CurrentUser.address return a lot of additional data, what I want is just the Email Address.
Thanks.
Andy Ho
--
Sue Mosher, Outlook MVP > Hi, > > How can I get the Email Address of the Login User from Outlook. > > The Me.Session.CurrentUser.address return a lot of additional data, what > I want is just the Email Address. > > Thanks. > > Andy Ho > > > >
This is returning the X400 name for your exchange server. I am not sure this is possible through the basic Outlook Object Model, you could use LDAP and query the Exchange server settings to get the SMTP based address. This newsgroup is more for VSTO Related queries.
Sample VBScript file
' Create the ADSystem Information Object
Set objADSystemInfo = CreateObject("ADSystemInfo")
' Get the current information into a new Object
Set objUser = GetObject("LDAP://" & objADSystemInfo.UserName)
'Now use the mail property for the SMTP Address
Wscript.Echo "SMTP Address: " & objUser.mail
Additionally you could use CDO but this isnt supported using Managed code :(
Regards
Thanks for the reply.
Really surprise that for a tool to write Outlook plug-in doesn't have any method to retrieve the user's email address. 8-(
Andy
Is there really no other way, to get the current user's e-mail address, than using Redemption in .Net 2005 (using C#) since Redemption is costly.
I heard something about asking Active Directory for the e-mail address by giving it the current username (which is easy to retrieve).
If not, what about LDAP, could someone please show some example code on how to do that in C#? (that visual basic script above here really confuses me) ;)
Thanks in advance
Magnus
Hi Mike,
It seems that the code snippet u have put could be of my help in my scenarios.
Can you let me know, how to use ur code in the InfoPath 2003 forms to get the
current user and his Manager's name and email IDs from the Exchange Server.
I need to display them on an InfoPath 2003 form.
Thanx for any help.
Mike,
I have tried placing the code in the onload event, but I am getting an error on the line below:
Set objUser = GetObject("LDAP://" & objADSystemInfo.UserName)
with the message saying "A runtime error has occured. Do you want to debug - Y/N".
And the debugger stops at this line.
Not sure about this LDAP thing, as I am a newbee.
Can u explain me why are we using LDAP and not anything else.
Moreover can you reply me soon, so that I may give you more details to get this issue resolved.
Thanx again in advance.
--
Hi Mike,
It seems that the code snippet u have put could be of my help in my scenarios.
Can you let me know, how to use ur code in the InfoPath 2003 forms to get the
current user and his Manager's name and email IDs from the Exchange Server.
I need to display them on an InfoPath 2003 form.
Thanx for any help.
string username = txtUsername.Text;
DirectoryEntry domain = new DirectoryEntry("LDAP://adserver");
DirectorySearcher searcher = new DirectorySearcher(domain);
searcher.Filter = "(samaccountname=" + username + ")";
SearchResult result = searcher.FindOne();
foreach (DictionaryEntry property in result.Properties)
{
Panel pnlResult = new Panel();
Label newLabel = new Label();
Label newValue = new Label();
newLabel.Text = property.Key + ": ";
newLabel.ID = property.Key.ToString();
newLabel.Font.Bold = true;
newValue.Text = GetProperty(result, property.Key.ToString());
pnlResult.Controls.Add(newLabel);
pnlResult.Controls.Add(newValue);
pnlResults.Controls.Add(pnlResult);
}