Subject: RE: How to send “Show single category” embedded view in Email?
You’ll need to use Lotus Script for this.
Get a collection of your documents.
Either thorught a search, to get a true collections
Or by scanning each document in a view, and processing only those you need.
Use the RichText methods to build a report in a new document.
Append data from the document fields
Append a link to the document
Once the report is built, e-mail it.
I’ll include an example that one of my databases uses below.
Public Class recipient
Public Name As String
Public outstanding() As notesdocument
End Class
Sub Initialize
' Define the working items
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
' These are the Rich-text styles we want to have on the note
Set norm = session.CreateRichTextStyle
norm.bold = False
norm.underline = False
norm.fontsize = 10
norm.notescolor = COLOR_BLACK
Set BBU = session.CreateRichTextStyle
BBU.bold = True
BBU.underline = True
BBU.fontsize = 12
BBU.notescolor = COLOR_BLACK
Set BOLD = session.CreateRichTextStyle
BOLD.bold = True
Set UNBOLD = session.CreateRichTextStyle
UNBOLD.bold = False
Set RED = session.CreateRichTextStyle
RED.NotesColor = COLOR_RED
Set BLUE = session.CreateRichTextStyle
BLUE.NotesColor = COLOR_BLUE
Set GREEN = session.CreateRichTextStyle
GREEN.NotesColor = COLOR_DARK_GREEN
' Define the list to hold the recipients
Dim sendto List As recipient
' Get the DB pointer
Set db = session.CurrentDatabase
' Get the view
Set View = db.GetView( "Customer Status Documents" )
' Loop through the documents to be processed by this agent
Set doc = view.GetFirstDocument
While Not(Doc Is Nothing)
%REM
We need to deside if this document needs a reminder created.
The criteria are ...
Ignore EDI documents
All new documents
All documents pending review
All documents under review
and NOT archived
%END REM
' Check for EDI documents
service = doc.Service(0)
' Check for NEW documents
status = doc.Status(0)
' Check for documents under review
rflag = doc.RFlag(0)
' Check for documents needing review
review = doc.Next_Review(0)
' Ignore archived documents
archive = doc.Archived(0)
If service <> "EDI" And (status = "New" Or rflag = "1" Or review < Today) And archive <> "Yes" Then
' Add the item to the reminder list
' See if we need to create this recipient
who = doc.Rep(0)
If Not Iselement(sendto(who)) Then
Set sendto(who) = New recipient
Set userName = New NotesName(who)
sendto(who).name = userName.Common
Redim Preserve sendto(who).outstanding(0)
End If
num = Ubound(sendto(who).outstanding) +1
Redim Preserve sendto(who).outstanding(num)
Set sendto(who).outstanding(num) = doc
End If
Set doc = view.GetNextDocument(doc)
Wend
' Now we have all of the documents processed, build a report for each Rep
Forall person In sendto
Set memo = New NotesDocument(db)
memo.Subject = "Customer Status Review memo"
Set pic = memo.ReplaceItemValue( "_ViewIcon", 34 )
Set rtitem = New notesrichtextitem(memo, "Body")
Call rtitem.addnewline(1)
Call rtitem.AppendStyle( norm )
Call rtitem.appendtext("Good morning " + person.name + ". This is your weekly report on Customer Status documents that require your attention.")
' Get the number of documents
count = Ubound(person.outstanding)
Call rtitem.addnewline(2)
Call rtitem.appendtext(" The following are the documents that require your attention. Please update each document, ")
Call rtitem.addnewline(1)
Call rtitem.appendtext(" and conduct a COS review with the customer for STANDARD and EXTENDED customers")
Call rtitem.addnewline(2)
Call rtitem.appendtext(" Once all information is updated, press the [Document Reviewed by Rep] button.")
Call rtitem.addnewline(2)
Dim open_for As Integer
For i = 1 To count
Set doc = person.outstanding(i)
status = doc.Status(0)
rflag = doc.RFlag(0)
review = doc.Next_Review(0)
If status = "New" Then
Call rtitem.AppendStyle( BLUE )
Call rtitem.appendtext(" This document is in NEW status and needs to be SUBMITTED. ")
Elseif rflag = "1" Then
Call rtitem.AppendStyle( GREEN )
Call rtitem.appendtext(" This document is assigned to you and needs to be reviewed. ")
Elseif review < Today Then
Call rtitem.AppendStyle( RED )
Call rtitem.appendtext(" This document has just been assigned to you and needs to be reviewed. ")
' Mark is as under review
doc.RFlag = "1"
' Update the log
existing_log = doc.Notes(0)
new_log = Now + " - " + session.CommonUserName + " : Status changed to Under Review by weekly agent."_
+ Chr(10) + " " + Chr(10) + existing_log
doc.Notes = new_log
Call doc.save(False,False)
Else
Call rtitem.AppendStyle( RED )
Call rtitem.appendtext(" *** OPPS - This document was selected but I don't know why. ")
End If
Call rtitem.appenddoclink(doc,"Customer Status Document")
Call rtitem.addnewline(1)
reviewed = doc.last_reviewed(0)
If reviewed = "" Then
Call rtitem.appendtext(" This record has never been reviewed")
Else
open_for = Today - reviewed
Call rtitem.appendtext(" It has been " +Str(open_for) +" days since this record has been reviewed")
End If
Call rtitem.addnewline(1)
status = doc.Cust_Status(0)
If status = "Base" Then
Call rtitem.appendtext(" This is a BASE customer, so no COS review is required")
Elseif status = "Standard" Then
Call rtitem.appendtext(" This is a STANDARD customer, so a COS review is required")
Else
Call rtitem.appendtext(" This is an EXTENDED customer, so a COS review is required")
End If
Call rtitem.addnewline(1)
Call rtitem.appendtext(" Customer Name : " + doc.Customer_Name(0))
Call rtitem.appendtext(" Service : " + doc.Service(0))
Call rtitem.addnewline(2)
Call rtitem.AppendStyle( NORM )
Next
Call rtitem.AppendStyle( UNBOLD )
Call rtitem.appendtext("--- End of Report ---")
Call memo.Send(False, Listtag(person)+"@IBMCA" )
Delete memo
End Forall
End Sub