Solved

Creating a scheduled Agent !!!

Posted on 2003-11-03
9
251 Views
Last Modified: 2013-12-18
I need  to write an agent that loops through all the documents in a view (parent and child) and
sees if the "date_expired" field is with in 5 days of current date and then send out an email.
I would appreciate a basic skeleton code, something to start me off.
0
Comment
Question by:apparition
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9672225
Follow this steps

1. Create new agent and enable schedule
2. Click on Add Search button and select condition By Field
3. Select the field, and select option is in the last... and set it to 5 and Click OK button
4. Click on Add Action... button in Program pane and select Send Mail Message and set necessary parameters.

Save the agent and test

~Hemanth
0
 
LVL 14

Accepted Solution

by:
p_partha earned 75 total points
ID: 9672308
Are u looking for something like this:


      Dim session As New notessession
      Dim db As notesdatabase
      Set db = session.currentdatabase
      Set view = db.getview("<yourviewname>")
      Set doc  = view.getfirstdocument
      While Not doc Is Nothing
            dates = "10/27/2003" ' instead of this replace it iwth ur doc.<fieldname>
            Set t = New notesdatetime(dates)
            Set t1 = New notesdatetime(Today)
            If t1.TimeDifference(t)/86400 > 5 Then
                  Set maildoc = db.createdocument
                  maildoc.form = "memo"
                  maildoc.subject ="<somesubject>"
                  Set rtitem = New NotesRichTextItem ( maildoc, "Body" )
                  Call rtitem.AppendDocLink _
                  ( view, view.Name & " in " & db.Title )
                  maildoc.send False
            End If
            Set doc = view.getnextdocument(doc)
      Wend

change the view name and the dates value...

Partha
0
 
LVL 5

Author Comment

by:apparition
ID: 9672476
Partha

where do I specify the who I want to send the email to ?

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Author Comment

by:apparition
ID: 9672535
got it maildoc.Sendto
0
 
LVL 5

Author Comment

by:apparition
ID: 9672602
heres the code I'm using, but I'm getting a type mismatch error

Sub Initialize
      Dim session As New notessession
      Dim db As notesdatabase
      Set db = session.currentdatabase
      Set view = db.getview("Label Management")
      Set doc  = view.getfirstdocument
      While Not doc Is Nothing
            dates = doc.fldExpiry ' instead of this replace it iwth ur doc.<fieldname>
            Set t = New notesdatetime(dates)
            Set t1 = New notesdatetime(Today)
            If t1.TimeDifference(t)/86400 < 5 Then
                  Set maildoc = db.createdocument
                  maildoc.form = "memo"
                  maildoc.subject ="Expired Docs"
                  maildoc.SendTo ="Jon Doe"
                  Set rtitem = New NotesRichTextItem ( maildoc, "Body" )
                  Call rtitem.AppendDocLink _
                  ( view, view.Name & " in " & db.Title )
                  maildoc.send False
            End If
            Set doc = view.getnextdocument(doc)
      Wend
      End SubNavigator
End Sub

Also, I need to send a list of all the expired documents in one email
not a separate email for each expired doc.

Thanks for your help
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9674955
Hemantha's code wll work much better for you, and you can set an action to send newsetter, which will show the results as a document with a docLink to each found item.
0
 
LVL 5

Author Comment

by:apparition
ID: 9678804
I would ideally want  to get p_partha's code to work.

0
 
LVL 5

Author Comment

by:apparition
ID: 9678970
got it to work

heres the code I used

Dim session As notessession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim view As NotesView
Dim item As NotesItem
Set session = New NotesSession
      Set db = session.currentdatabase
      Set view = db.getview("Label Management")
      Set doc  = view.GetFirstDocument
      While Not doc Is Nothing
            Set item = doc.GetFirstItem( "fldExpiry" )
            Dim t As New NotesDateTime( item.Text)
            Dim t1 As New NotesDateTime("Today")
            If t1.TimeDifference(t)/86400 < 5 Then
                  Set maildoc = db.createdocument
                  maildoc.form = "memo"
                  maildoc.subject ="bla"
                  maildoc.SendTo ="Malik Arefin"
                  Set rtitem = New NotesRichTextItem ( maildoc, "Body" )
                  Call rtitem.AppendDocLink _
                  ( view, view.Name & " in " & db.Title )
                  maildoc.send False
            End If
            Set doc = view.getnextdocument(doc)
      Wend
0
 
LVL 14

Expert Comment

by:p_partha
ID: 9679010
sorry,
I didn't get any mail that comments were added, so cudn't see the posts...

thx for the points

Partha
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to copy mail box rules from one nsf to another 9 203
Lotus notes VB code 4 213
Switching from Lotus Notes to Outlook 4 69
Scan to Email - HP 477 Printer and Lotus Notes 8 98
For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question