【问题标题】:Can't get to any info from Lotus Notes using VBA无法使用 VBA 从 Lotus Notes 获取任何信息
【发布时间】:2017-06-13 11:49:04
【问题描述】:

提前感谢您的帮助!

我最终会尝试根据主题行从特定电子邮件中提取信息。解决这个问题,下面的代码是一个提取主题行的测试。然而,它浏览了 132 个文档,没有一个主题被识别为空白以外的任何内容。使用相同的 Initialize 和 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

【问题讨论】:

    标签: excel lotus-notes vba


    【解决方案1】:

    你的问题是这一行:

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

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

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

    【讨论】:

    • 您完全正确,找到了正确的数据库。感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多