[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


What's running after my "Before new mail arrives" agent?

Posted on 2010-09-09
Medium Priority
Last Modified: 2013-12-18
I'm trying to write an agent in LotusScript that removes the field "Form" from incoming messages that meet a certain criteria. I've gotten the code to work, based on results in the agent log, but the problem is this: after the code runs on the incoming messages, the value of field "Form" is reset to <trouble value>. These messages are generated by our voicemail system and contain attached .wav files; I need to clear the Form field so that, instead of trying to use the embedded java player, you can just play the .wav file through whatever media player is set in the OS. There's a ton of code on the form.

Is there, somewhere, a concise list of what events are triggered when a new message arrives? Is it plausible that something in the messages' contents is resetting this field after the "Before new mail arrives" agent runs? I'd prefer not to make this an "after new mail arrives" agent to avoid the delay that that entails.

Any help is greatly appreciated.

Question by:ben_wall
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
LVL 22

Expert Comment

ID: 33644284
Hmm, I have to admit that I don't understand why wouldn't you use "after new mail arrives"?
The delay, you're talking about, will be determined only by your code and you must put the code somewhere, so why not put it in the event that's invented exactly for situations like yours.

Why exactly are you removing the form field?
LVL 22

Expert Comment

ID: 33644302
OK, I see why.
Look (in Designer) at form properties, Launch tab. There you'll find settings about which player is used.

The workaround (if you're not allowed to make changes to the form) would be to copy the form, name it differently, and change launch properties.
Then, in your agent, instead of removing Form field, simply change the value (to your new form's name).
LVL 46

Expert Comment

by:Sjef Bosman
ID: 33644318
Removing the Form-field in a pre-arrival agent seems like a bad idea to me. Notes doesn't really required that field, but much depends on it actually. You could set it to a different value though, e.g. "MemoX" or so.

There are only pre-arrival and post-arrival agents, nothing else gets triggered when a mail comes in. And you're right, the pre-arrival agent runs immediately, on the arriving mail itself, whereas the post-arrival agent runs like any other agent (which allows you to use UnprocessedDocuments).

What I don't understand is your story about the embedded player. Does Notes have an embedded player to run WAV files? And if so, what does that have to do with the Form field? Or is there some function placed on the Memo-form that you want to circumvent? Did you modify the Memo form of the standard mail template?

Maybe there are more and better ways to accomplish what you want, besides just changing the Form field... I'd need more information to be able to find that out.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 46

Expert Comment

by:Sjef Bosman
ID: 33644339
Ah, Marko, also "assuming" ? There is really a delay, it can be many minutes depending on the server's current load. Yes, there is probably a parameter to bring that delay down, but the agent will never run immediately.

I didn't know about the form properties' launch tab settings, I have to admit I never really understood what it's for :-P Does that also override the right-mouse click?
LVL 22

Expert Comment

ID: 33644390
How do you mean "Does it override right-mouse click", it reacts with specified (in form properties) action on form's QueryOpen or PostOpen event.
Like launching the first attachment (or embedded OLE), playing specified vaw file,...
I also never used this, but I have tried it once upon a time :)


is there any code in the form's QueryOpen or PostOpen events? It could be possible that the launch is coded there, instead of using form launch properties.

Author Comment

ID: 33647100
Thanks for the comments, so it seems I need to provide more info.

This is the Domino Unified Communication template, StdR85UCMail, and the form is fa_RcvdVoiceMail. This adds an embedded .wav player, and a bunch of automation, for voice mail messages. Unfortunately, there is no version of this template for the Mac version of Notes, and no version for the iNotes web interface on any browser except Internet Explorer (and as an organization, we recommend FireFox.) We found that if we programmatically remove the Form field, then you get a plain message with a .wav attachment that, when launched, uses the OS media player; otherwise, it doesn't work at all in iNotes on FireFox/Chrome/Safari, and you get multiple error messages in Notes for the Mac.

The problem with the after mail is received agent is that it takes too long to work; the delay is unacceptable for this purpose. Thus, the before mail arrives agent... but it doesn't seem to work as expected, or, rather, it seems to run (based on what's showing up in the agent log,) but the Form field is not changed. If I run a version of the code modified for the Action menu, it works fine. I've attached my code, if that helps. You can see I've gone through a couple of iterations of removing or changing the Form field.

So, I'm open to suggestions. The goal is to have a plain text email with a .wav attachment that can be played normally on any platform.

Thanks very much for your help.
Sub Initialize()
Dim s As New NotesSession
Dim d As NotesDatabase
Dim doc As NotesDocument
Dim fld As NotesItem
Dim chk As NotesItem
Dim dbug As NotesLog

Set dbug=New NotesLog("Router Log")
Call dbug.Openagentlog()
dbug.Logaction("Preprocessing agent begin--->>")

Set d = s.currentdatabase
'Set col=d.unprocesseddocuments
'Set doc=col.getfirstdocument()
Set doc=s.Documentcontext
Set chk=doc.Getfirstitem("Subject")
dbug.Logaction("doc subject is: " & chk.text)
If InStr(chk.text,"Voice Mail Message") Then
	'Set fld=doc.Getfirstitem("Form")
	Call doc.Replaceitemvalue("Form", "Memo")
	'Call doc.Removeitem("Form")
	'Call doc.Replaceitemvalue("Form", "")
	Call doc.Save(True, False, False)
	Set fld=doc.getfirstitem("form")
	If InStr(fld.text,"Memo") Then
		dbug.logaction("form apparently changed")
	End If
End If

dbug.Logaction("<<---Preprocessing agent done")
Call dbug.Close
End Sub

Open in new window

LVL 22

Accepted Solution

mbonaci earned 2000 total points
ID: 33647161
Aha, I see, your problem is that it (sometimes) takes too long for "after mail arrives" agent to respond, right?

There is a setting in Notes.ini with which you can control how often Agent manager checks for un-triggered messages.

It is called AMgr_UntriggeredMailInterval

This setting specifies a delay (in minutes) between running of the Agent Manager's check for untriggered mail. Valid values are 1 minute to 1440 minutes (the number of minutes in a day). The default value is 60 minutes.

See here, in the comment I posted, for all other mail agent related params in Notes.ini:

Author Comment

ID: 33647529
That's a great idea. I checked our server docs and found that they are all set to the default of only 1 concurrent agent. After checking with the other Notes admin here, we're going to try upping that to 10 to see if that makes a difference, and then we'll try the AMgr_UntriggeredMailInterval. Although it's set to default, we see "after mail arrives" agents running in just a few minutes - which is still too slow for the voicemail messages.
I'll let you know how it turns out, although this may take a couple of days.
LVL 46

Expert Comment

by:Sjef Bosman
ID: 33651091
@Marko, did you read my previous post? ;-)

Two remarks on the code:
- you're not supposed to save the document inside a pre-arrival agent, the document is yet to be saved by the server
- you could indeed change the contents of the Form field into the name of a different form, one that you prepare without the voicemail activation option

Author Closing Comment

ID: 33674826
Your linked article provided the solution - Controlling how many concurrent agents are running. After increasing the number of concurrent agents from 1 to 10 on all incoming servers, the "After mail arrives" agent is almost instantaneous.

Thanks very much.

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

649 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