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



提前感谢您的任何帮助!

我最终试图根据主题行从特定电子邮件中提取信息。为了解决这个问题,下面的代码是一个测试来拉出一个主题行。 但是,它贯穿了 132 个文档,没有一个主题被标识为空白以外的任何内容。 使用相同的初始化和 GetDatabase 方法,我成功地通过 Lotus Notes 发送电子邮件,所以我认为我不以某种方式追求错误的文档。 下面通过Excel用VBA编写的代码有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")

您正在打开名称.nsf。这是用户的个人通讯簿数据库。它不是用户的邮件数据库。您之前发送邮件的工作之所以有效,是因为您无需访问邮件数据库即可发送邮件。您可以从任何地方发送邮件。为了阅读邮件,您必须打开邮件数据库。

类的 OpenMailDatabase 方法为您提供了一种查找和打开当前用户的邮件数据库的简单方法。

最新更新