Dim body As New NotesRichTextItem(doc, "Body")
REM Create table in Body item
rowCount% = 4
columnCount% = 3
Call body.AppendTable(rowCount%, columnCount%)
REM Populate table
Dim rtnav As NotesRichTextNavigator
Set rtnav = body.CreateNavigator
Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)
For iRow% = 1 To 4 Step 1
For iColumn% = 1 To 3 Step 1
Call body.BeginInsert(rtnav)
Call body.AppendText("your value from row's column")
Call body.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Next
Next
Dim ses As New NotesSession
Dim db As NotesDatabase
Dim coll As NotesDocumentCollection
Dim doc As NotesDocument
Dim mailDoc As NotesDocument
Dim stream As NotesStream
Dim body As NotesMIMEEntity
Dim child As NotesMIMEEntity
Set db = ses.CurrentDatabase
html$={<table>
<th><td>Header 0</td><td>Header 1</td><td>Header 2</td></th>
}
'Get your document collection:
'Set coll = ...
'Generate table content:
Set doc = coll.GetFirstDocument
Do While Not doc Is Nothing
html$ = html$ & {
<tr><td>} & doc.Field0(0) & {</td><td>} & doc.Field1(0) & {</td><td>} & doc.Field2(0) & {</td></tr>}
Set doc = coll.GetNextDocument(doc)
Loop
html$ = html$ & {
</table>}
'Generate excel file:
'fileName$ = "SomeFile.xlsx"
'filePath$ = "C:\SomeFolder\" & fileName$
'Create mail document:
Set mailDoc = db.CreateDocument
mailDoc.Subject = subject$
mailDoc.SendTo = mails
ses.ConvertMIME = False
'Add html to mail body:
Set stream = ses.CreateStream
Set body = mailDoc.CreateMIMEEntity
Call stream.WriteText(html$)
Call body.SetContentFromText(stream, "text/html; charset=UTF-8", ENC_IDENTITY_8BIT)
'Add attachment:
Set child = body.CreateChildEntity
Set header = child.CreateHeader("Content-Disposition")
Call header.SetHeaderValAndParams(|attachment; filename="| & fileName$ &|"|)
Set stream = ses.CreateStream
stream.Open filePath$, "binary"
child.SetContentFromBytes stream, "application/octet-stream", ENC_IDENTITY_BINARY
child.EncodeContent ENC_BASE64
Call mailDoc.CloseMIMEEntities(True, "Body")
'Send mail:
Call mailDoc.Send(False)
3 回答
我将使用在此描述的方法:http://blog.texasswede.com/dynamic-tables-in-classic-notes/
基本上,您要做的是创建一个表单,在其中放置要显示在每一行上的字段。然后,在代码中循环浏览 Notes 文档集合,并为每个文档创建一个行模板文档,填充其中的字段并将该文档作为富文本格式呈现到电子邮件的正文(富文本)字段中。
使用NotesViewNavigator类从具有GetFirstDocument和GetNextDocument的视图中读取前 10 个文档。用notesViewEntry.ColumnValues读取列值。
将值写入 RichText 表。这是例如何创建和填充它:
您可以使用
MIME
并通过HTML
功能生成 e-mail 的内容,例如,可以在 e-mail 中生成此表:这是示例: