【问题标题】:extract multiple recipient email address from the Lotus Notes using VBA使用 VBA 从 Lotus Notes 中提取多个收件人电子邮件地址
【发布时间】:2022-01-15 07:03:04
【问题描述】:

我编辑了从 Internet 获得的 VBA 代码,以便从 CC 字段中获取收件人电子邮件地址和所有电子邮件地址。下面的代码仅显示一个电子邮件地址,但有多个收件人。如何编辑以下程序以从 SendTo 和 CopyTo 字段中获取所有收件人。

Public Sub Get_Notes_Email_Address()
Dim NSession As Object      'NotesSession
Dim NMailDb As Object       'NotesDatabase
Dim NDocs As Object         'NotesDocumentCollection
Dim NDoc As Object          'NotesDocument
Dim NNextDoc As Object      'NotesDocument
Dim NItem As Object         'NotesItem
Dim view As String
Dim vn As Integer
Dim filterText As String

filterText = "text to search"

Set NSession = CreateObject("Notes.NotesSession")
'Set NMailDb = NSession.CurrentDatabase
Set NMailDb = NSession.getDatabase("<SERVERNAME>", "<LOCATION>")
'MsgBox NMailDb.AllEntries()

If Not NMailDb.IsOpen Then
    NMailDb.OPENMAIL
End If

Set NDocs = NMailDb.AllDocuments 

If filterText <> "" Then
    NDocs.FTSEARCH filterText, 0
End If
'MsgBox NDocs.Count
Set NDoc = NDocs.GetFirstDocument
'MsgBox NDocs.GetFirstDocument


vn = 2
Do Until NDoc Is Nothing
    Set NNextDoc = NDocs.GetNextDocument(NDoc)
    Set NItem = NDoc.GETFIRSTITEM("Body")
    If Not NItem Is Nothing Then
   
        Cells(vn, 3) = NDoc.GETITEMVALUE("Subject")(0)
        'MsgBox prompt:=NDoc.GETITEMVALUE("CopyTo")(0), Title:="CopyTo"
        Cells(vn, 4) = NDoc.GETITEMVALUE("CopyTo")
        'MsgBox prompt:=NDoc.GETITEMVALUE("SendTo")(0), Title:="SendTo"
        Cells(vn, 5) = NDoc.GETITEMVALUE("SendTo")
        
        
        
        
    End If
    Set NDoc = NNextDoc
    vn = vn + 1
   
    
Loop
'reset all objects to null
Set NMailDb = Nothing
Set NSession = Nothing

结束子

【问题讨论】:

    标签: vba lotus-notes lotus-domino email-client


    【解决方案1】:

    您在这一行中调用 GetItemValue:

    Cells(vn, 4) = NDoc.GETITEMVALUE("CopyTo")
    

    这个函数返回一个数组。你需要将它读入一个变量,而不是直接将它检索到单元格中。你需要编写一个循环来检查这个变量作为一个数组——复制这个数组的条目,从下标零开始,到你的单元格中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-24
      • 2011-08-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多