我在 LotusScript 中有一个代理,它构建了一个格式整齐的文档链接和描述表,用作每月提醒摘要。当我手动运行它(Agent-Run)时,它会发送一条与代码匹配的完美格式的消息。
但是,当我安排同一个代理时,输出会丢失所有表格样式以及附加的文档链接。这使得出站电子邮件毫无用处。服务器在 ACL 中作为经理,所有检查的角色都具有与我的 ID 相同/更高的权限。在代理属性中,安全设置为 3 级,以允许具有完全管理权限的受限操作。
期权公开期权声明
Sub Initialize Dim session As New NotesSession Dim db As NotesDatabase Set db = session.currentdatabase Dim docs, keydocs As NotesDocumentCollection Dim keydoc, doc As NotesDocument Dim dt As New NotesDateTime(Today) Dim dtstr, key As String, svr As String, sendto As string Dim mfgview, dptview As NotesView Dim reldb As NotesDatabase Set reldb = session.Getdatabase("Server", "db.nsf") Dim relview As NotesView Set relview = reldb.Getview("(Categorized docs-Rev_ob)") Dim bkmdoc作为notesdocument
Set mfgview = db.Getview("DutyRosterMaint") 'mfg dept
Set dptview = db.Getview("2-5 years dept") 'docs needed to be reviewed
Dim j, keydocct, keyct As Integer
Dim vardp, varnm As Variant
vardp = Evaluate({@DBColumn("":"Nocache";@DBName;"DutyRosterMaint"; 1)})'get dept name in array
keyct = UBound(vardp)
If keyct > 0 Then
Set keydoc = mfgview.GetFirstDocument
'Do Until keydoc Is Nothing
For j = 0 To keyct-1
key = vardp(j)
varnm = Evaluate({@DBLookup("":"Nocache";@DBName;"DutyRosterMaint";"}& key &{";2;[FailSilent])})
Set docs = dptview.Getalldocumentsbykey(key, true)
Dim dcct, i, cellnm As Integer
dcct = docs.count
If dcct>0 Then
Dim maildoc1 As New NotesDocument ( db )
Dim rtitem1 As New NotesRichTextItem ( maildoc1, "Body" )
Call rtitem1.AppendText ("Hello,")
Call rtitem1.AddNewLine ( 2)
Dim bodytxt As String
bodytxt = "This is an automated monthly email. "&_
"You are receiving this email because you are listed as the reviewer responsible for the documents below." &_
Chr$(13) & Chr$(13) &_
"The documents listed have not been revised in in 2 years (xx) or 5 years (all other types).Please determine if these documents are still necessary, accurate and suitable for use or coordinate with the appropriate individual to conduct the review." &_
Chr$(13) & Chr$(13) &_
"When done, the 'Set Review Date' button must be clicked on each document to reset the document review date. " &_
Chr$(13) & Chr$(13) &_
"If you have any questions or need assistance, please contact me or refer to BKM-0013 section VIII for additional guidance. " &_
Chr$(13) & Chr$(13) &_
"Thank you, "
Call rtitem1.AppendText (bodytxt)
Call rtitem1.AppendDocLink(bkmdoc, "xx-0013")
Call rtitem1.AppendText( " xx-0013")
Call rtitem1.AddNewLine ( 2)
Dim rtnav As NotesRichTextNavigator
Set rtnav = rtitem1.Createnavigator
Dim richStyle As NotesRichTextStyle
Set richStyle = session.CreateRichTextStyle
richStyle.Bold = True
richStyle.Underline = True
richStyle.FontSize = 12
Call rtitem1.Appendstyle(richStyle)
Call rtitem1.AppendText (key)
Set richStyle = session.CreateRichTextStyle
richStyle.Bold = False
richStyle.Underline = False
richStyle.FontSize = 10
Call rtitem1.Appendstyle(richStyle)
Call rtitem1.AddNewLine ( 1)
Dim rtt As NotesRichTextTable
Dim styles(0 To 5) As NotesRichTextParagraphStyle
'link
Set styles(0) = session.CreateRichTextParagraphStyle
styles(0).Alignment = 0
styles(0).Firstlineleftmargin = 0
styles(0).Leftmargin = 0
styles(0).RightMargin = RULER_ONE_CENTIMETER * 0.7
'approval date
Set styles(1) = session.CreateRichTextParagraphStyle
styles(1).Alignment = 0
styles(1).Firstlineleftmargin = 0
styles(1).Leftmargin = 0
styles(1).RightMargin = RULER_ONE_CENTIMETER * 2
'docnum
Set styles(2) = session.CreateRichTextParagraphStyle
styles(2).Alignment = 0
styles(2).Firstlineleftmargin = 0
styles(2).Leftmargin = 0
styles(2).RightMargin = RULER_ONE_CENTIMETER * 2
'title
Set styles(3) = session.CreateRichTextParagraphStyle
styles(3).Alignment = 0
styles(3).Firstlineleftmargin = 0
styles(3).Leftmargin = 0
styles(3).RightMargin = RULER_ONE_CENTIMETER * 7.5
'rev
Set styles(4) = session.CreateRichTextParagraphStyle
styles(4).Alignment = 0
styles(4).Firstlineleftmargin = 0
styles(4).Leftmargin = 0
styles(4).RightMargin = RULER_ONE_CENTIMETER * 0.8
'last editor
Set styles(5) = session.CreateRichTextParagraphStyle
styles(5).Alignment = 0
styles(5).Firstlineleftmargin = 0
styles(5).Leftmargin = 0
styles(5).RightMargin = RULER_ONE_CENTIMETER * 4
Set rtt = rtnav.Getfirstelement(RTELEM_Type_Table)
Call rtitem1.Appendtable(dcct+1, 6,,, styles)
maildoc1.Form = "Memo"
If varnm(0) = "" THen
maildoc1.SendTo = "Test"
Else
maildoc1.SendTo = varnm
End if
Dim devnm(2) As Variant
devnm(1) = "Test"
maildoc1.SendTo = devnm
maildoc1.CopyTO = "Test"
maildoc1.Subject = "Process Document Review Due for: " & key
Set doc = docs.Getfirstdocument()
'link
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , 1)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText("Link")
Call rtitem1.EndInsert
'approval date
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , 2)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText("Approval Date")
Call rtitem1.EndInsert
'docnum
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , 3)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText("Doc Num")
Call rtitem1.EndInsert
'title
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , 4)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText("Title")
Call rtitem1.EndInsert
'rev
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , 5)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText("Rev")
Call rtitem1.EndInsert
'last editor
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , 6)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText("Last Editor")
Call rtitem1.EndInsert
cellnm = 7
For i = 1 To dcct
If doc.Status(0) = "Approved" then
'link
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , cellnm)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendDocLink(doc, doc.DocNum(0))
Call rtitem1.EndInsert
'approval date
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , cellnm+1)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText(doc.DisplayAppDate(0))
Call rtitem1.EndInsert
'docnum
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , cellnm+2)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText(doc.DocNum(0))
Call rtitem1.EndInsert
'title
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , cellnm+3)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText(doc.Subject(0))
Call rtitem1.EndInsert
'rev
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , cellnm+4)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText(CStr(doc.Revision(0)))
Call rtitem1.EndInsert
'last editor
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , cellnm+5)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText(doc.LastEditor(0))
Call rtitem1.EndInsert
Else
If doc.Revision(0) > 1 Then
Dim reldc As NotesDocument
Set reldc = relview.Getdocumentbykey(doc.DocNum(0), True)
If Not (reldc Is Nothing) Then
'link
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , cellnm)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendDocLink(reldc, reldc.DocNum(0))
Call rtitem1.EndInsert
'approval date
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , cellnm+1)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText(reldc.DisplayAppDate(0))
Call rtitem1.EndInsert
'docnum
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , cellnm+2)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText("*"&reldc.DocNum(0))
Call rtitem1.EndInsert
'title
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , cellnm+3)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText(reldc.Subject(0))
Call rtitem1.EndInsert
'rev
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , cellnm+4)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText(CStr(reldc.Revision(0)))
Call rtitem1.EndInsert
'last editor
Call rtnav.Findnthelement(RTELEM_TYPE_TABLECELL , cellnm+5)
Call rtitem1.Begininsert(rtnav)
Call rtitem1.AppendText(reldc.LastEditor(0))
Call rtitem1.EndInsert
End If
End If
End if
Set doc = docs.getnextdocument(doc)
cellnm = cellnm +6
Next
svr = UCase(db.Server)
If InStr(svr, "DEV") > 0 Or svr = "" Then
Call rtitem1.Addnewline(1)
If varnm(0) = "" Then
sendto = "Test"
Else
sendto = "Test"
End If
Call rtitem1.Addnewline(3)
Call rtitem1.AppendText( "-------------------------------------------------------------------------------------------------")
Call rtitem1.Addnewline(1)
Call rtitem1.AppendText( "Bypassed delivery for testing from being delivered to : " & sendto)
maildoc1.sendto = "Test"
Call maildoc1.Send( true )
Else
Call maildoc1.Send( true )
End If
End If
'Set keydoc = mfgview.getnextdocument(keydoc)
'Loop
next
MsgBox "Notifications have been sent successfully."
End If
结束子