Examples: FormatMsgWithDoclinks method

  1. This view action script gets a collection of the documents currently selected in the view. It creates a newsletter containing links to each document in the collection, and saves it in the current database.
    Sub Click( Source As Button )
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim collection As NotesDocumentCollection
      Dim newsletter As NotesNewsletter
      Dim doc As NotesDocument
      Set db = session.CurrentDatabase
      Set collection = db.UnprocessedDocuments
      Set newsletter = New NotesNewsletter( collection )
      Set doc = newsletter.FormatMsgWithDoclinks( db )
      doc.Form = "Summary"
      Call doc.Save( True, True )
    End Sub
  2. This script performs a full-text search on the current database, creates a newsletter containing links to each document in the resulting collection, and saves the newsletter to SCIENCE.NSF on the current computer. The documents containing the most instances of the word "botany" are sorted at the beginning of the collection, so their links appear at the beginning of the newsletter. Each document's full-text relevance score is listed next to its link.
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim summaryDb As NotesDatabase
    Dim collection As NotesDocumentCollection
    Dim newsletter As NotesNewsletter
    Dim doc As NotesDocument
    Set db = session.CurrentDatabase
    Set summaryDb = New NotesDatabase _
    ( "", "summary\science.nsf" )
    Set collection = db.FTSearch( "botany", 0 )
    Set newsletter = New NotesNewsletter( collection )
    newsletter.DoScore = True
    Set doc = newsletter.FormatMsgWithDoclinks( summaryDb )
    doc.Subject = "Garden of Botanical documents"
    doc.Form = "Summary"
    Call doc.Save( True, True )
  3. This agent script runs on all new and modified documents. It performs a full-text search on the unprocessed documents in the current database, creates a newsletter containing links to each document in the resulting collection, and mails the newsletter to Susanna Tallan. Each document's relevance score and Topic item are listed in the newsletter next to the document's link.

    The script then marks each document as processed so that the UnprocessedFTSearch method does not search for these documents the next time the agent runs.

    Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim collection As NotesDocumentCollection
      Dim newsletter As NotesNewsletter
      Dim doc As NotesDocument  
      Dim j As Integer
      Dim originalDoc As NotesDocument    
      Set db = session.CurrentDatabase
      Set collection = db.UnprocessedFTSearch( "botany", 0 )
      Set newsletter = New NotesNewsletter( collection )
      newsletter.DoScore = True
      newsletter.DoSubject = True
      newsletter.SubjectItemName = "Topic"
      Set doc = newsletter.FormatMsgWithDoclinks( db )
      doc.Subject = "New botany documents from this week"
      doc.Form = "Memo"
      Call doc.Send( False, "Susanna Tallan" )
      ' mark all documents in newsletter's collection as 
      ' processed, so that they aren't included in the 
      ' newsletter next time
      Set originalDoc = collection.GetFirstDocument
        Do Until originalDoc Is Nothing
        Call session.UpdateProcessedDoc( originalDoc )
        Set originalDoc = collection.GetNextDocument(originalDoc)
      Loop
      Next
    End Sub