Sub SignMail(title As String,emp As String,sctman As String,doc As NotesDocument,db As NotesDatabase)
Dim mailDoc As NotesDocument
Set mailDoc = New NotesDocument(db)
Dim sender As String
Dim st(100) As String
Dim ct(2) As String
sender = ""
Const Macro$ = "@Elements(_CurrentAPREmpNo)"
result = Evaluate(Macro$, doc)
For i = 0 To Cint(result(0)) - 1
st(i) = doc.~_CurrentAPREmpNo(i)
Next i
ct(0) = emp
ct(1) = sctman
mailDoc.Form = "Memo"
mailDoc.SendTo = st
mailDoc.CopyTo = ct
mailDoc.Subject = title
Set RTItem = mailDoc.CreateRichTextItem("Body")
Call RTItem.AddNewLine(1)
Call RTItem.AppendText("Document Link Icon -->")
Call RTItem.AppendDocLink(doc, doc.docno(0))
Call mailDoc.Send(False)
End Sub
Sub Initialize
Dim ws As New NotesUIWorkspace
Dim ns As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim ncol As Integer
Dim nrow As Integer
Set db=ns.CurrentDatabase
Set view = db.GetView("View-ForSign1")
Dim i As Integer
i = 1
Set doc = view.GetFirstDocument
While Not (doc Is Nothing)
Call SignMail("【催签通知】E-RunCard System---(" & doc.lotid(0) & ") from(" & doc.EMPNO(0) & " " & doc.EmpEname(0) & ") needs your approval",doc.EMPNO(0),doc.sctman(0),doc,db)
i = i + 1
Print "E-runcard test"
Set doc = view.GetNextDocument(doc)
Wend
Call mailformes(i,db)
End Sub
Sub mailformes(i As Integer,db As NotesDatabase)
Dim mailDoc As NotesDocument
Set mailDoc = New NotesDocument(db)
mailDoc.Form = "Memo"
mailDoc.SendTo = "PQMES"
mailDoc.Subject = "E-runcard催签邮件执行情况"
Set RTItem = mailDoc.CreateRichTextItem("Body")
Call RTItem.AddNewLine(1)
Call RTItem.AppendText("今日共发出" & i & "封催签邮件!")
Call mailDoc.Send(False)
End Sub
PS : 手动执行又不报错,调试也没有问题,求大神帮忙看哈哪儿出错了~~~~
自动运行报错如下:
2014-05-27 13:45:33 AMgr: Start executing agent '每天自动催签1' in 'APTPeRuncard.nsf' by Executive '1'
2014-05-27 13:45:33 AMgr: 'ZARA WU/ProQ' is the agent signer of agent '每天自动催签1' in 'APTPeRuncard.nsf'
2014-05-27 13:45:33 AMgr: 'Agent '每天自动催签1' in 'APTPeRuncard.nsf' will run on behalf of 'ZARA WU/ProQ'
2014-05-27 13:45:33 Agent '每天自动催签1' in database 'APTPeRuncard.nsf' signed by 'ZARA WU/ProQ' is running in Full Administrator mode
2014-05-27 13:45:33 AMgr: Agent ('每天自动催签1' in 'APTPeRuncard.nsf') error message: Error creating product object
收起