How to access current logged in user email address in lotus script?

怎甘沉沦 提交于 2020-05-16 22:00:41

问题


I am looking to find the email address of the current notes client user who is logged in programmatically. Is there a way to do it ? I am accessing username with session but I need email address Thanks in advance.


回答1:


From the Help database, part of an example for the getMailInfo method:

Dim session As New NotesSession
Dim db As NotesDatabase
Dim mynotesdir As NotesDirectory
Set mynotesdir  = session.getDirectory("server name")    
Dim homeserver As Variant

homeserver =  mynotesdir.GetMailInfo(session.UserName, True) ' or EffectiveUserName
Msgbox "internetMailAddress: " + Cstr(homeserver(7))



回答2:


You will need to look up the e-mail address in the organisation's address book(s) (names.nsf).

Here is a slightly modified code from the Designer help,where you use s.Username use to search through the Address book(s) for the email address.

Sub Click(Source As Button)
    Dim session As New NotesSession
    Dim books As Variant
    Dim view As NotesView
    Dim doc As NotesDocument
    Dim done As Variant
    Dim person As String

    books = session.AddressBooks
    done = False

    Forall b In books
      ' check every Domino Directory,
      ' unless we're already done
      If ( b.IsPublicAddressBook ) And ( Not done ) Then
        Call b.Open( "", "" )
        ' look up person's last name
        ' in People view of address book
        Set view = b.GetView( "($People)" )
        Set doc = view.GetDocumentByKey( session.Username )
        ' if person is found, display the email address  
        ' from the Person document
        If Not ( doc Is Nothing ) Then
          Messagebox( "Email for " + person " is " + doc.InternetAddress( 0 ) )
          done = True
        End If
      End If
    End Forall

  ' if done is still False, the person wasn't found
    If Not done Then
      Messagebox( "Sorry, unable to locate person's email." )
    End If
  End Sub


来源:https://stackoverflow.com/questions/61519697/how-to-access-current-logged-in-user-email-address-in-lotus-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!