如何访问莲花脚本中当前登录的用户电子邮件地址?

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

我正在查找以编程方式登录的当前 notes 客户端用户的电子邮件地址。有办法吗?我正在使用会话访问用户名,但我需要电子邮件地址 提前致谢。

您需要在组织的地址簿 (names.nsf) 中查找电子邮件地址。

这是来自 Designer 帮助的稍微修改过的代码,您可以在其中使用 s.Username 用于在地址簿中搜索电子邮件地址。

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

来自帮助数据库,getMailInfo 方法示例的一部分:

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))