【问题标题】:Remainder Mail agent提醒邮件代理
【发布时间】:2013-05-22 09:10:07
【问题描述】:

我的表单包含 3 个字段地址、状态、报告日期。

地址字段包含 mil 必须发送到的 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 版本可能也会对您有所帮助。

标签: lotus-notes agent lotusscript


【解决方案1】:

不使用任何错误处理是非常糟糕的做法。但是您的错误很可能会发生在 sendmailtouser- 子程序中,您在其中调暗了一个名为 db 的本地 notesdatabase- 对象,而没有实际初始化它。

线

set maildoc = New NotesDocument( db ) 

会失败。 要么全局声明 db 并将其设置在您的初始化中,要么再次在该 sub 中设置 db 并再次设置 db(最坏的情况是您必须为每个文档都这样做)

【讨论】:

  • 全局声明数据库,现在工作正常..非常感谢
猜你喜欢
  • 1970-01-01
  • 2018-12-09
  • 1970-01-01
  • 2013-06-29
  • 1970-01-01
  • 1970-01-01
  • 2011-10-27
  • 2015-11-12
  • 2018-01-15
相关资源
最近更新 更多