无法使用 VBA 从 Lotus Notes 获取任何信息

Can't get to any info from Lotus Notes using VBA

在此先感谢您的帮助!

我最终试图根据主题行从特定电子邮件中提取信息。解决这个问题,下面的代码是一个拉出主题行的测试。然而,它贯穿了 132 份文件,没有一个主题被识别为空白以外的任何内容。使用相同的 Initialize 和 GetDatabase 方法,我成功地通过 Lotus Notes 发送了电子邮件,所以我不认为我在寻找错误的文档。下面用 VBA 到 Excel 编写的代码有 Lotus Notes 8.5

有人知道为什么我在 Notes 数据库中的所有文档中只能得到空白吗?

Sub LotusGetView()

Dim Nsess As New NotesSession
Dim Ndb As NotesDatabase
Dim Ndocs As NotesDocumentCollection
Dim Ndoc As NotesDocument, docNext As NotesDocument
Dim c As Long
Dim memSubj As Variant


Nsess.Initialize
Set Ndb = Nsess.GetDatabase("", "names.nsf")

Set Ndocs = Ndb.AllDocuments

c = 1

Set Ndoc = Ndocs.GetFirstDocument
Do Until Ndoc Is Nothing Or c = 1000
    Set docNext = Ndocs.GetNextDocument(Ndoc)

    memSubj = Ndoc.GetItemValue("Subject")(0)

    If memSubj <> "" Then

        MsgBox memSubj

    End If


    Call Ndoc.Remove(True)

    Set Ndoc = docNext

    c = c + 1
Loop

MsgBox c

End Sub

你的问题是这一行:

Set Ndb = Nsess.GetDatabase("", "names.nsf")

您正在打开 names.nsf。那就是用户的个人通讯录数据库。它不是用户的邮件数据库。您之前发送邮件的工作之所以成功,是因为您无需访问邮件数据库即可发送邮件。您可以从任何地方发送邮件。要阅读邮件,您必须打开邮件数据库。

OpenMailDatabase method of the NotesDbDirectory class 为您提供了一种查找和打开当前用户邮件数据库的简便方法。