我有3個字段的地址,狀態,ReportingDate的形式。剩餘郵件代理
地址字段包含密鑰必須發送的ID。
現在我創建了一個代理,在狀態不完整且報告日期恰好在今天的日期前7天時,它將郵件發送到地址字段中的數據。
我的代碼:
Option Public
Option Declare
Sub Initialize
Dim sess As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim timestamp As New NotesDateTime("Today")
Dim Noresponsedate As NotesDateTime
Dim vw As NotesView
Dim diff As Integer
Dim SendTo As Variant
Call timestamp.SetNow()
Set db = sess.CurrentDatabase
Set vw = db.GetView("data")
Set doc = vw.GetFirstDocument()
While Not doc Is Nothing
If doc.Status(0) = "Incomplete" Then
Call checktimedifference(doc)
End if
Set doc = vw.GetNextDocument(doc)
wend
End Sub
Sub checktimedifference(doc As NotesDocument)
Dim due As NotesDateTime
Dim present As NotesDateTime
Dim timecheck As variant
Set due = New NotesDateTime ("")
Set present = New NotesDateTime ("Today")
timecheck = doc.ReportingDate(0)
due.LSLocalTime = timecheck
If due.TimeDifference (present) = -604800 Then
Call sendmailtouser(doc)
End If
End Sub
Sub sendmailtouser(doc As NotesDocument)
Dim db As NotesDatabase
Dim rtiitem As NotesRichTextItem
Dim maildoc As NotesDocument
dim recepient As variant
Set maildoc = New NotesDocument(db)
Set rtiitem = New NotesRichTextItem(maildoc, "Body")
recepient = doc.adress(0)
maildoc.from = db.Title
maildoc.form = "memo"
maildoc.subject = "A Minor Injury Report:" & doc.Seq_No(0) & " needs your response"
maildoc.SendTo = recepient
Call rtiitem.AppendText("Please respond to this Minor Injury Report")
Call rtiitem.AddNewline(2)
Call rtiitem.AppendText("Your response for the Minor Injury Report: " & doc.Seq_No(0) & " is required")
Call rtiitem.AddNewline(2)
Call rtiitem.AppendText("Please click on the following link to access the document.")
Call rtiitem.AppendDocLink(doc, db.Title)
Call maildoc.Send(False)
End Sub
當我運行在客戶端代理我收到以下錯誤:
請幫我解決了錯誤,併發送郵件到受助。
在調試器中運行代碼以確定哪一個代碼正在生成錯誤,並相應地更新您的問題。然後有人可能真的能夠幫助你。它可能也會幫助你說出你使用的是什麼版本的Lotus Notes。 –