• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 524
  • Last Modified:

Get Lotus email address by programming

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.


0
melodiesoflife
Asked:
melodiesoflife
  • 2
2 Solutions
 
madheeswarCommented:
How you are getting User Name?
Like:
@name([cn];@username)?

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:
@dbLookup("":"";"Servername":"names.nsf";"($Users)";@name([cn];@username);columnnum)

like that
0
 
melodiesoflifeAuthor Commented:
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.
0
 
madheeswarCommented:
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
tmpemail=doc.Internetaddress(0)
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.
-maddy
0
 
qwaleteeCommented:
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")
    session.Initialize("Password")
    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
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now