@mailsend sending multiple emails in scheduled agent


I am trying to use @mailsend in a scheduled agent.
I am working accept for one problem...

The @mailsend is sending an email for each document. I only want it to send 1 email!

Basically I am using @elements and if the view contains more than 100 documents based on certain criteria a single email should be sent.

Currently if 48 documents match this criteria, 48 emails are sent.

How can I ensure that only 1 email is sent.

LVL 21
Who is Participating?
Sorry..it was my mistake.
For Scheduled agents you cannot have none.
Since it's my fault, use this code....Tested and it is working. Make it a Scheduled agent and run on all documents. Provide your email in tmpname..

Sub Initialize
	Dim ss As New NotesSession 
	Dim db As NotesDatabase 
	'Dim view As notesview
	'Dim dc As NotesDocumentCollection 
	'Dim doc As NotesDocument 
	Dim maildoc As NotesDocument 
	Set db=ss.CurrentDatabase 
	tmptotal = Evaluate(|@Elements(@DbColumn("";"";"List";1))|)
	If Isempty(tmptotal) Or tmptotal(0) < 100 Or tmptotal(0)="" Then Exit Sub
	'Send email:
	Set maildoc = New NotesDocument( db )
	maildoc.Form = "Memo"
	maildoc.Subject = "Reminder: Please Review New Application"
	Set Body=New NotesRichTextItem(maildoc,"Body")
	message="Please Review the New Application"
	Call Body.AppendText(message)
	Call Body.AddNewLine(2)
	tmpname = "Your Mail addess"
	Call maildoc.Send( True, tmpname ) 
End Sub

Open in new window

You will need to switch to LotusScript to accomplish this.  Is that OK?
shuboarderAuthor Commented:
That's fine, but I wouldn't know how to write it in LotusScript....
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Post your agent code, and I'll see what I can do.
shuboarderAuthor Commented:
Hi Bill,

very kind of you. Are you sure we can't do something clever with the formula below?

body := "this database needs attention etc."

@MailSend("some.address@something.com";"";"";"Database Alert!";"";body;[PriorityHigh]);

check the agent properties settings. It should run Scheduled and run on none.
shuboarderAuthor Commented:
Hi madheeswar,

this would make sense, but you can't have a scheduled agent with a target of "none" or can you?
shuboarderAuthor Commented:
I don't seem to be able to run with a target of none unless I select to run on event.
shuboarderAuthor Commented:
Thanks Madheeswar, this seems to be working well!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.