使用 VBA 从 Lotus Notes 中提取多个收件人电子邮件地址

问题描述 投票:0回答:2

我编辑了从互联网上获得的 VBA 代码,以便从抄送字段中获取收件人电子邮件地址和所有电子邮件地址。下面的代码仅显示一个电子邮件地址,但有多个收件人。如何编辑以下程序以获取 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
2个回答
2
投票

您在这一行中调用 GetItemValue:

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

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


0
投票

我也面临着同样的问题。您是否能够更改代码以读取抄送和密件抄送值。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.