Reminder Agent

I want to use the below script to send out scheduled reminders but am not sure about the Sendto.  I want to grab a list of manager from the first column of a view called ManagerList. Can someone help?

Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim doc As NotesDocument
      Dim body As NotesRichTextItem
      
      Set db = session.CurrentDatabase
      Set doc = db.CreateDocument()
      doc.form = "Memo"
      doc.Sendto = ""
      doc.Subject = "Asset Reminder for Managers and Supervisors"
      Set body = doc.CreateRichTextItem("body")
     '  ....   Set the contents of the Body with the RichTextItem methods
      Call body.AppendText( "This a weekly scheduled reminder to collect any assets from Terminated Employess and to distribute any assets to New Employees.  Then, update the Users Profile document accordingly in the Asset Tracking Database" )
      Call doc.Send(False)
End Sub
schmad01Asked:
Who is Participating?
 
p_parthaCommented:
Try this:

Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim doc As NotesDocument
    Dim body As NotesRichTextItem

set view = db.getview("Managerlist")
set viewdoc = view.getfirstdocument
while not viewdoc is nothing
Set doc = db.CreateDocument()
    doc.form = "Memo"
    doc.Sendto = ""
    doc.Subject = "Asset Reminder for Managers and Supervisors"
    Set body = doc.CreateRichTextItem("body")
    '  ....   Set the contents of the Body with the RichTextItem methods
    Call body.AppendText( "This a weekly scheduled reminder to collect any assets from Terminated Employess and to distribute any assets to New Employees.  Then, update the Users Profile document accordingly in the Asset Tracking Database" )
doc.sendto = viewdoc.rename
    Call doc.Send(False)
set viewdoc = view.getnextdocument(viewdoc)
wend
0
 
p_parthaCommented:
Somethign in this lines:


   Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim doc As NotesDocument
    Dim body As NotesRichTextItem

set view = db.getview("Managerlist")
set viewdoc = view.getfirstdocument
while not viewdoc is nothing
Set doc = db.CreateDocument()
    doc.form = "Memo"
    doc.Sendto = ""
    doc.Subject = "Asset Reminder for Managers and Supervisors"
    Set body = doc.CreateRichTextItem("body")
    '  ....   Set the contents of the Body with the RichTextItem methods
    Call body.AppendText( "This a weekly scheduled reminder to collect any assets from Terminated Employess and to distribute any assets to New Employees.  Then, update the Users Profile document accordingly in the Asset Tracking Database" )
doc.sendto = viewdoc.columnvalue(0)
    Call doc.Send(False)
set viewdoc = view.getnextdocument(viewdoc)
wend
0
 
schmad01Author Commented:
Not working. Getting

For the DIM session as New NotesSession I'm getting:  Illegal executable code in Declarations.

I took that out for the hell of it and test ran the agent, then got:

Object variable not set
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
p_parthaCommented:
Did you put the code inside the initialize

partha
0
 
schmad01Author Commented:
Yes.
0
 
p_parthaCommented:
remove all teh code from declarations and paste my code in initialize

partha
0
 
schmad01Author Commented:
Ok, I did what you said, then tried to save and got:  Illegal executable code at the module level
0
 
p_parthaCommented:
can you create  a new agent and write this code in initialize. Just paste this in between initialize not anywhere else

partha
0
 
schmad01Author Commented:
Ok, now errors on saving. When I test ran it, Object variable not set popped up.  Put in debugging mode and it got the error at this line:

Set view = db.getview("Managerlist")
0
 
p_parthaCommented:
above that line
jsut give htis:

set db = session.currentdatabase

Partha
0
 
schmad01Author Commented:
That got rid of that error. Now getting a popup saying:

Notes error: No names found to send mail to.

The view name is correct. Does the column have to be sorted?
0
 
schmad01Author Commented:
It is sorted Ascending. Not categorized.  FYI
0
 
p_parthaCommented:
can u tell me what is there in first column (i mean the fieldname)

Thanks
partha
0
 
schmad01Author Commented:
Column formula is @Name([CN];rename)
0
 
schmad01Author Commented:
That's it!  Thanks alot, Partha!
0
 
p_parthaCommented:
Thanks
Also make sure once the mail is sent the document is out of the view...

- Partha
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.