Link to home
Start Free TrialLog in
Avatar of ben_wall
ben_wall

asked on

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

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.

~ben
Avatar of mbonaci
mbonaci
Flag of Croatia image

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?
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).
Avatar of Sjef Bosman
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.
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?
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 :)

http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=/com.ibm.designer.domino.main.doc/H_ABOUT_FORMS_THAT_LAUNCH_OBJECTS_AUTOMATICALLY.html

ben_wall,
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.
Avatar of ben_wall
ben_wall

ASKER

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")
dbug.Logactions=True
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

ASKER CERTIFIED SOLUTION
Avatar of mbonaci
mbonaci
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
@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
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.