需求:通过Lotusscript代码创建会议日程,要求程内容包含HTML格式的表格

分析:看到表单设计,Notice表单的Body域是RTF类型

Sub SendMIMEMail(recipients As Variant,ccTo As Variant,bccTo As Variant, Subject As String,bodyHtmlContent As String)
	On Error Goto errhandle
	Dim body As NotesMIMEEntity
	Dim stream As NotesStream
	Dim session As New NotesSession  
	Dim message As NotesDocument
	Dim db As NotesDatabase  
	Dim dtStart As NotesDateTime  
	Dim dtEnd As NotesDateTime  
	Dim subject1 As String  
	Dim location As String  
	Dim categories As String  
	
    ' 初始化数据库  
	Set db = session.CurrentDatabase  
	
    ' 创建新的会议通知文档  
	Set message = db.CreateDocument  
	
    ' 设置会议日期和时间  
	Set dtStart = New NotesDateTime("2024-09-24 16:00:00")  
	Set dtEnd = New NotesDateTime("2024-09-24 18:00:00")  
	
    ' 设置用户、主题、地点和类别  
	user1 = "test/RAISINGSTAR" ' 确保替换为有效的用户  
	subject1 = "项目进展会议"  
	location = "会议室A"  
	categories = "项目, 进展"  
	' 开始之前,不对MIME做富文本转换
	session.ConvertMIME = False 
	Set stream = session.CreateStream
	Set body = message.CreateMIMEEntity
	message.SendTo = user1
	message.Subject = subject1  
	message.Location = location  
	' 转换为本地时区
	message.StartDateTime = dtStart.LSLocalTime
	message.StartDate = dtStart.LSLocalTime
	message.StartTime = dtStart.LSLocalTime
	message.EndDateTime = dtEnd.LSLocalTime
	message.EndDate = dtEnd.LSLocalTime
	message.EndTime = dtEnd.LSLocalTime
	message.calendarDateTime = dtStart.LSLocalTime
	message.Categories = categories  
	message.CopyTo =ccTo
	message.BlindCopyTo =bccTo
	message.RecNoOutOfOffice = "1"   
	message.form="notice"
	Call stream.WriteText (bodyHtmlContent)
	' 设置MIME字符集为UTF-8,确保内容识别为HTML
	Call body.SetContentFromText (stream, "text/html;charset=UTF-8", ENC_NONE) 
	' 加上签名,更有可信
	message.Principal = "administrator/RAISINGSTAR"
	Call message.Send (False)  		
	session.ConvertMIME = True ' Restore conversion
	Exit Sub
errhandle:

	Exit Sub
End Sub

Sub Click(Source As Button)
	Dim Bodyhtmlcontent As String
	Bodyhtmlcontent=|尊敬的用户,您好!<br>您被邀请参与以下会议,请您准时出席。<table style='FONT-SIZE: 14px;background-color:#FEFBFD;border-collapse:collapse;  border: 1px solid #0D0C0D;TEXT-ALIGN: left;table-layout:fixed;' ><tr><td style=' padding:5px;border-collapse:collapse; border:1px solid #0D0C0D;word-wrap:break-word;word-break:break-all;'>会议主题:</td><td colspan='3' style=' padding:5px;border-collapse:collapse; border:1px solid #0D0C0D;word-wrap:break-word;word-break:break-all;'>admin的会议20240919162341</td></tr>|
	Bodyhtmlcontent=Bodyhtmlcontent+|<tr><td style=' padding:5px;border-collapse:collapse; border:1px solid #0D0C0D;word-wrap:break-word;word-break:break-all;'>会议平台:</td><td colspan='3' style=' padding:5px;border-collapse:collapse; border:1px solid #0D0C0D;word-wrap:break-word;word-break:break-all;'>MS Teams</td></tr>|
	Bodyhtmlcontent=Bodyhtmlcontent+|<tr><td style=' padding:5px;border-collapse:collapse; border:1px solid #0D0C0D;word-wrap:break-word;word-break:break-all;'>会议开始时间:</td><td colspan='3' style=' padding:5px;border-collapse:collapse; border:1px solid #0D0C0D;word-wrap:break-word;word-break:break-all;'>2024-09-24 16:00</td></tr>|
	Bodyhtmlcontent=Bodyhtmlcontent+|<tr><td style=' padding:5px;border-collapse:collapse; border:1px solid #0D0C0D;word-wrap:break-word;word-break:break-all;'>预计结束时间:</td><td colspan='3' style=' padding:5px;border-collapse:collapse; border:1px solid #0D0C0D;word-wrap:break-word;word-break:break-all;'>2024-09-24 18:00</td></tr>|
	Bodyhtmlcontent=Bodyhtmlcontent+|<tr><td style=' padding:5px;border-collapse:collapse; border:1px solid #0D0C0D;word-wrap:break-word;word-break:break-all;'>召集人:</td><td colspan='3' style=' padding:5px;border-collapse:collapse; border:1px solid #0D0C0D;word-wrap:break-word;word-break:break-all;'>admin/RAISINGSTAR</td></tr>|
	Bodyhtmlcontent=Bodyhtmlcontent+|<tr><td style=' padding:5px;border-collapse:collapse; border:1px solid #0D0C0D;word-wrap:break-word;word-break:break-all;'>会议室:</td><td colspan='3' style=' padding:5px;border-collapse:collapse; border:1px solid #0D0C0D;word-wrap:break-word;word-break:break-all;'>测试会议室</td></tr>|
	Bodyhtmlcontent=Bodyhtmlcontent+|</table><br><br>--------------------------------------------<br><br>请勿回复本邮件,如有疑问请联系系统管理员或会议室管理员。|
	
	Call SendMIMEMail("bhtest/RAISINGSTAR", "administrator/RAISINGSTAR","", "test notice", Bodyhtmlcontent)
	Msgbox "测试日历发送成功"
End Sub

执行效果:

收件人打开后: