1

下面的代码片段是,首先准备邮件,然后为每个文档添加一个文档链接,最后发送邮件。

我在 doc.SentTo =addresses.abbreviated 处未设置对象变量

Dim s As NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim i As Integer
Dim view As NotesView

Set s = New NotesSession
Set db = s.CurrentDatabase
Set view = db.GetView("View")
Set doc = New NotesDocument(db)
Dim addresses As NotesName
i=0
'- prepare mail
doc.SendTo = addresses.abbreviated
doc.Form = "Memo"
Set rtitem = New NotesRichTextItem(doc, "Body")
Call rtitem.AppendText("Balance")

Set doc = view.GetFirstDocument
While Not(doc Is Nothing)
    Set addresses = New NotesName(doc.Manager(0)) 
    If addresses.abbreviated = "" Then
    i = i + 1
Else 
    '- Append descriptive text, link and new line
    Call rtitem.appendtext(doc.Subject(0) & "  " )
    Call rtitem.appenddoclink(doc, "Link")
    Call rtitem.addnewline(1)
    i = i + 1
End If
Set doc = view.GetNextDocument(doc)
Wend
'- send mail
Call doc.Send (True)

帮助将不胜感激。

4

1 回答 1

2

我在这里看到两个问题。一是地址尚未设置为对象。另一个是您已将 doc 变量用于要发送的电子邮件并遍历一组文档。

更改这些行:

Set doc = New NotesDocument(db)
Dim addresses As NotesName

为此,或类似的东西:

Set mailDoc = New NotesDocument(db)
Dim addresses As New NotesName("email recipient user name")

mailDoc.SendTo = addresses.abbreviated
mailDoc.Form = "Memo"
Set rtitem = New NotesRichTextItem(mailDoc, "Body")

还将底部的 doc 变量更改为 mailDoc :)

于 2015-05-27T11:42:34.653 回答