Solved

Help creating a Nag Agent

Posted on 2006-10-27
7
329 Views
Last Modified: 2013-12-18
I would like to create a Nag agent that will run daily to send an email to whoever is listed in the SendTo field of the document.

I have set up a view called "Nagview" which is correctly displaying a list of all the documents I wish to Nag about.
Now I need help with the agent which is to run through this view and send a document link to the relevant person along with an annoying message like "You have not updated this document for 30 days, please click the link below to do this now!"

Here is what I have written so far....am I going the right way here?
Any help towards this much appreciated!

Sub Initialize
      Dim ses As New NotesSession
      Dim db As NotesDatabase
      Dim view As NotesView
      Dim doc As NotesDocument
      
      Set db= ses.CurrentDatabase
      Set view= db.GetView("Nagview")
      Set doc= view.GetFirstDocument
      Do Until doc Is Nothing
         Call doc.Send( False, [SendTo])
         Set doc= view.GetNextDocument(doc)
      Loop
End Sub
0
Comment
Question by:shuboarder
7 Comments
 
LVL 21

Author Comment

by:shuboarder
ID: 17818232
Sorry slight typo...

Sub Initialize
     Dim ses As New NotesSession
     Dim db As NotesDatabase
     Dim view As NotesView
     Dim doc As NotesDocument
     
     Set db= ses.CurrentDatabase
     Set view= db.GetView("Nagview")
     Set doc= view.GetFirstDocument
     Do Until doc Is Nothing
        Call doc.Send( False, "SendTo")
        Set doc= view.GetNextDocument(doc)
     Loop
End Sub

I can set the SendTo to be myself, and I do receive lots of emails, but when I try and open the email I just get
"cannot locate form:"
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17818291
Try a

set doc.form="memo"

too

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17818310
Without the SET of course... doh!
doc.form="memo" befor you call doc.send

This is sending the document itself not a doclink though.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 21

Author Comment

by:shuboarder
ID: 17818744
thanks for that Steve,

I had managed to figure that one out in time...

Here is the current non-working code:

Sub Initialize
      Dim ses As New NotesSession
      Dim db As NotesDatabase
      Dim view As NotesView
      Dim doc As NotesDocument
      Dim rtitem As NotesRichTextItem
      
      Set db= ses.CurrentDatabase
      Set view= db.GetView("Nagview")
      Set doc= view.GetFirstDocument
      Set rtitem = doc.NotesRichTextItem(doc, "Body")
      Do Until doc Is Nothing
            doc.form="memo"
            doc.subject="Document requires your attention"
            doc.body="You have not updated this document in the past 30 days, please do so now!"
            Call rtitem.AppendDocLink(doc, "Body")
            Call doc.Send( False, "SendTo")
            Set doc= view.GetNextDocument(doc)
      Loop
End Sub

any idea how I can include a doclink?
I am trying to do this using NotesRichTextItem above.
Is this the correct method?

Thanks
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 17818966
I would think that you need to docs, the original, and the one you want to send.
Use the copy all fields to transfer the fields over, and then just change just the fields needed, or look at the newsletter option to understand how to send doc links.

I hope this helps !
0
 
LVL 18

Accepted Solution

by:
marilyng earned 175 total points
ID: 17826716
Hee. hee.... I found that putting the subject: ESCALATION NOTICE!! in my "nag" e-mails resulted in an immediate response.  

However, you need to instantiate a maildoc in your loop:

Sub Initialize
     Dim ses As New NotesSession
     Dim db As NotesDatabase
     Dim view As NotesView
     Dim doc As NotesDocument
     Dim rtitem As NotesRichTextItem
     
     Set db= ses.CurrentDatabase
     Set view= db.GetView("Nagview")
     Set doc= view.GetFirstDocument
     While not doc is Nothing
        Dim maildoc as New NotesDocument (db)
         Set rtitem = New NotesRichTextItem(maildoc,"Body")
         maildoc.principal = "some.name"
         maildoc.from = "some.name"
         maildoc.subject = "ESCALATION NOTICE!! " + ="Document requires your attention"
         with rtItem
            .addnewline 1
            .appendText ="You have not updated this document in the past 30 days, please do so now!"
            .addNewLIne 1
            .appendDocLink doc, "Doc link to the document"
            .appendText "  << Click here to open the document"
            .addNewLine 1
         end with
          maildoc.sendTo = "somesendtoname"
          maildoc.send false
          set maildoc = nothing
          set rtItem = nothing
        set doc = view.getNextDocument(doc)
    wend

End Sub

Or something like that.. not tested.. :)  I always add ESCALATION NOTICE in red, and other options to the email.  Also, as sysExpert suggests .. and this is a bit more complicated, rather than spamming the nag notices, I usually step through a notes navigator and send a newsletter of all the links.

But this should get you started.  
0
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 75 total points
ID: 17826812
Missed the previous replies back there... agreed re: the newsletter type format, I tend to write it manually with more control over the layout and content of mails and sort the view by person then when stepping down it one mail is sent per person containing links to each of their docs but it depends upon the app.  In some apps it is unlikely there is more than one doc. per person in which case a mail per doc. is relatively acceptable.

Snippets of the code I use, this is based on a view sorted by person.  The way I do it is to use a fixed pitch font and then have a single column (3) in the view containing all the fields I want to show to the user and the column title for that column laid out with the titles to show, perhaps not the best way but meant one lot of code for multiple different reports.

Not meant as a complete solution for you, may give you some more ideas to work with too though.

Steve

View:   column1 = person name, sorted.  column2 = details to show in link, column3 = rest of line to show.

Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim rtitem As notesrichtextitem
Dim richStyle As NotesRichTextStyle
Dim view As notesview
Dim vc As notesviewentrycollection
Dim entry As notesviewentry
Dim sendto As Variant

Const viewname="TL_Report"
Const description="Team Leader"

' Create handle onto new document to send as email      
      Dim session As New notessession
      Set db=session.currentdatabase
      
' Check if on server
      If db.server="" Then
            Print "Scheduled script stopped on local database copy"
            End
      End If
      
' Create rich text style for amending boldness of type etc.
      Set richStyle = session.CreateRichTextStyle

set view=db.getview(viewname)
      
' Use dbcolumn to get list of unique names that need reporting to:
  Dim result As Variant
  result = Evaluate(|@unique(@trim(@DbColumn( "" : "NoCache" ; "" : "" ; "| & viewname & |" ; 1)))|)
      
'Step through list of users and send report for each:
  Forall user In result
    Print "Sending "& description & " report for " & user
    SendReport (user)
  End Forall

Sub SendReport(person As String)
      
'Create new document to send as 'newsletter'      
      Dim newsdoc As New notesdocument(db)
      Dim i As Long
      
'Search view for this person's entries
      Set vc= View .GetAllEntriesbyKey( person,True)
      
'Setup rich text parameters
      Set rtitem = New NotesRichTextItem( newsDoc, "Body")
      
'Start of message body
      richStyle.Bold = True
      richStyle.notesfont=FONT_HELV
      Call rtitem.AppendStyle(richStyle)
      Call rtitem.AppendText("Please review entries below.  You can click on the links next to each item to open each document.")
      Call rtitem.addnewline(2)
      
'Fixed pitch font, Heading Underlined, Blue
      richstyle.notesfont=FONT_COURIER      
      richstyle.notescolor=COLOR_DARK_BLUE
      richstyle.Bold=False
      richStyle.Underline= True
      Call rtitem.AppendStyle(richStyle)
      Call rtitem.AppendText("LINK" & "  " & View.columns(3).Title)
      
'Turn off underline, blue leaving in Courier font
      richStyle.Underline= False
      richstyle.notescolor=COLOR_BLACK
      Call rtitem.AppendStyle(richStyle)
      Call rtitem.addnewline(2)
      
'Iterate through filtered view and print line for each
      If vc.count<1 Then
            Call rtitem.AppendText("There are currently no matching documents for you.")
      Else
            For i=vc.count To 1 Step -1
                  Set entry=vc.getnthentry(i)
                  Call rtitem.AppendDocLink( entry.document, entry.columnvalues(2)) ' Doclink with hover details from view
                  Call rtitem.appendtext(Chr$(9) & entry.columnvalues(3)) ' pre-formatted report from view
                  Call rtitem.addnewline(1)
            Next
      End If
      
      newsDoc.Subject = "[Report] "& description & " review for "& person
      newsDoc.Form="Memo"
      newsdoc.SendTo=person
      
      Call newsdoc.Send(False)
      
End Sub
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now