简体   繁体   English

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

[英]extract multiple recipient email address from the Lotus Notes using VBA

I edited a VBA code that I got from the internet in order to fetch recipient email address and all email addresses from CC field.我编辑了从 Internet 获得的 VBA 代码,以便从 CC 字段中获取收件人 email 地址和所有 email 地址。 The code below is just showing only one email address, however there are multiple recipients.下面的代码只显示了一个 email 地址,但是有多个收件人。 How can I edit the below program to get all recipients from SendTo and CopyTo fields.如何编辑以下程序以从 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

End Sub结束子

You are calling GetItemValue in this line:您在此行中调用 GetItemValue:

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

This function returns an array.这个 function 返回一个数组。 Instead of retrieving it directly into the cell, you need to read it into a variable.您需要将其读入变量,而不是将其直接检索到单元格中。 You need to write a loop that examines this variable as an array -- copying the entries of this array, starting at subscript zero, into your cell.你需要编写一个循环来检查这个变量作为一个数组——复制这个数组的条目,从下标零开始,到你的单元格中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM