none
get Email Address from Outlook RRS feed

  • Question

  • Hi,

     

    Is there a way to get Current User's email address from outlook?

    I am unable to find it in registry nor local system.

     

    Any help using VB or WMI or any other way?

    And, How do outlook 'recognise' the user login and 'auto' login the designated email?

     

    I'm currently developing a VB.net system and i need to get the user's email.

     

    Help needed.

    Thanks,

    Elvin

    Wednesday, November 21, 2007 1:57 AM

Answers

  • What about Namespace.CurrentUser.Address?

     

    Login is handled through the user's account settings for the particular mail profile.

    Wednesday, November 21, 2007 3:41 AM
    Moderator
  • Hi Elvin,

     

    If you are working on:

    1.        VSTO 2005 Outlook Add In, you should use Globals.ThisApplication.Session

    2.       VSTO 2005 SE Outlook Add In, you should use Globals.ThisAddIn.Application.Session

    3.       If you are not working on VSTO, but Office Automation, you just need to get the Application object of Outlook. And then call its Session.CurrentUser.Mail as Sue already pointed out.

    For example, if you are using Winform to automate Outlook. The outlook already started. Then you can get the Application object like this:

    Dim app as Outlook.Application

     app = System.Runtime.InteropServices.Marshal.GetActiveObject(“Outlook.Application”)

    MessageBox.Show(app.Session.CurrentUser.Address)

    Hope this helps

     

    Thanks

    Ji

    Thursday, November 22, 2007 6:16 AM
    Moderator

All replies

  • What about Namespace.CurrentUser.Address?

     

    Login is handled through the user's account settings for the particular mail profile.

    Wednesday, November 21, 2007 3:41 AM
    Moderator
  • Hi Sue Mosher,

     

    Could you provide me with more details?

    Which Namespace. ?

     

    Thanks

    Elvin

    Wednesday, November 21, 2007 6:44 AM
  • In this context, Namespace is not a .NET namespace but the Namespace object, one of the basic objects of the Outlook object model, returned in a VSTO 2005 SE addin by Globals.ThisApplication.Session.
    Wednesday, November 21, 2007 1:51 PM
    Moderator
  • Hi Sue Mosher,

     

    I am unable to locate Globals.ThisApplication.Session.

    Any help please?

     

    and VSTO 2005 is visual studio ?? 2005

     

    Thanks

    Elvin

    Thursday, November 22, 2007 2:13 AM
  • Are you using VSTO 2005 SE or the original release?
    Thursday, November 22, 2007 2:28 AM
    Moderator
  • Hi Elvin,

     

    If you are working on:

    1.        VSTO 2005 Outlook Add In, you should use Globals.ThisApplication.Session

    2.       VSTO 2005 SE Outlook Add In, you should use Globals.ThisAddIn.Application.Session

    3.       If you are not working on VSTO, but Office Automation, you just need to get the Application object of Outlook. And then call its Session.CurrentUser.Mail as Sue already pointed out.

    For example, if you are using Winform to automate Outlook. The outlook already started. Then you can get the Application object like this:

    Dim app as Outlook.Application

     app = System.Runtime.InteropServices.Marshal.GetActiveObject(“Outlook.Application”)

    MessageBox.Show(app.Session.CurrentUser.Address)

    Hope this helps

     

    Thanks

    Ji

    Thursday, November 22, 2007 6:16 AM
    Moderator
  • Is there a way to do this in my C# Application?

     

    Wednesday, January 23, 2008 6:26 PM
  • Hi UtahRob,

     

    Almost the same.

    Code Snippet

    Outlook.Application app = null;

     app = System.Runtime.InteropServices.Marshal.GetActiveObject(“Outlook.Application”);

    MessageBox.Show(app.Session.CurrentUser.Address);

     

     

    If you need more assistance, you need to raise a new thread and describe more about your issue.

     

     

    Thanks

    Ji

     

    Thursday, January 24, 2008 1:43 AM
    Moderator
  • Try this...

    This gives exactly what you want...

    CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress;

    -Thanks...

    Thursday, May 6, 2010 10:56 AM
  • this is really the answers.

    Other MVPs' answers are based on their imagination and probably never tested their codes, unless outlook vsto changed a lot: CurrentUser.Address returns AD path of the user; CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress gives the real email address.

     

    Tuesday, November 2, 2010 3:10 AM