Unique mail send

dear all,i have a view perndingwith, in this let say 3 documents.

Suppose first and second documents is pending with Mr.X and third is pending with Mr.Y.

i write a schedule agent for mail send.


Dim session As New NotesSession

Dim currDb As NotesDatabase

Dim currDoc As NotesDocument	

Set currDoc=session.DocumentContext

Set currDb=session.CurrentDatabase

Dim view As NotesView 

Set view=currDb.GetView(“pendingWithMeMailsend”)

Set currDoc=view.GetFirstDocument

While Not currDoc Is Nothing

 'START MAIL SEND CODE

  Msgbox currDoc.pendingWith(0)

 'END MAIL SEND CODE

Set currDoc=view.GetNextDocument(currDoc)

Wend	

This agent send three mails, two to Mr.X and one to Mr.Y.But this is not my requirement, i want to send only one mail to Mr.X and one mail to Mr.Y.

what should i do.

thanx & regard

Rehan

Subject: Use a List

Iterate through the documents and don’t send the email right away. Instead, use a List variable with the recipient name as key, to record information about what you want to send that person. Then after you’re done going through documents, use Forall to iterate through your list and send just one memo to each person.

(Or, if the view is sorted by name, you don’t need the list. You can just build up a message for one person, and remember the name of the person from the last iteration. If the new name is different, send the message to the old person and start a new memo for the new person)