下面的代码片段是,首先准备邮件,然后为每个文档添加doclink,最后发送邮件。
我得到的对象变量未设置为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)
非常感谢帮助。
答案 0 :(得分:1)
我在这里看到两个问题。一个是尚未将地址设置为对象。另一个是您已将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:)