Get Lotus email address by programming

Posted on 2005-04-14
Last Modified: 2013-12-18
Hi all

In Lotus, I can get the user name, but cannot get email address.
How can I get email address of current account in Lotus.

I prefer a segment code in C#, but if your code in VB is OK.

Question by:melodiesoflife
    LVL 19

    Expert Comment

    How you are getting User Name?

    if it is for external purpose where u want to provide email address of the user, then the user should have proper Access to ACL of NAB and also u need to write some code to get it from there.

    like that
    LVL 6

    Author Comment

    Here is the code I get Username:

        Dim Session as Object
        Dim strUserName as String
        Set Session = CreateObject("Notes.NotesSession")
        strUserName = Session.UserName

    I don't understand your code, I prefer C# or VB.
    Thanks anyway.
    LVL 19

    Accepted Solution

    Dim Session as Object
    dim db as
        Dim strUserName as String
        Set Session = CreateObject("Notes.NotesSession")
        strUserName = Session.UserName

    Private Sub Command1_Click()
    Dim session As Object
    Dim db As Object
    Dim doc As Object
    Dim rtitem As Object
    dim view as object
    Set session = CreateObject( "Notes.NotesSession" )
    Set db = session.GetDatabase( "", "names.nsf" )
    set view=db.getview("($Users)")
    set doc=view.getdocumentbykey(session.username,true)
    If not doc is nothing then
    end if
    Set session = Nothing
    Set db = Nothing
    Set doc = Nothing
    End Sub

    'The above is a sample code and may not work as it is. basically I am Lotus Script guy and don't have touch with VB.
    But the above code will give fair idea to start.
    Best of Luck.
    LVL 31

    Assisted Solution

    In the Notes world, the user name IS the e-Mail address.  However, it gets converted to an Internet address format when being sent out (and vice versa).  The address it is converted to is TYPICALLY in the directory.  The C code to get this is not trivial, but using COM, relatively easy.

        Dim Session as Object
        Dim strUserName as String
        Set Session = CreateObject("Notes.NotesSession")
        strUserName = Session.UserName

    That uses OLE Automation, so it opens teh Notes client and requests the user password.  If you want to avoid this, use the COM classes instead, but you will need to know the user password in advance (unless you are running on the Domino server).  To do so, use Lotus.NotesSession instead of Notes.NotesSession, followed immediately by session.Initialize("Password string"). Otherwise, the rest of teh code will be mostly the same...

        Dim Session as Object
        Dim strUserName as String
        Set Session = CreateObject("Lotus.NotesSession")
        strUserName = Session.UserName
        Set catalog = session.getDbDirectory("") 'need directory object to get mail
        Set mail = catalog.openMailDatabase 'need mail to get name of mail server -- note, if user is running local (mobile) this will not work
        Set directory = session.getDatabase(mail.Server,"names.nsf") 'names.nsf is the Domino Directory
        Set userRecord = directory.getView("($Users)").getDocumentByKey(strUserName)
        strAddress = userRecord.getItemValue("InternetAddress")(0) 'retruns a one element string array

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
    IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now