logo

Having Trouble Getting New Mail Agents To Work

The first item on my list of proposed improvements to this site last week was:

Now we know who's replying to what, it's possible to add the option to be notified via email of any reply to your reply. No need to keep checking back for an answer!

The idea being you can get alerted when people reply to you reply/query, without needing to remember to check back. Much more likely you'll get your answer that way.

Further to this I wanted to add another bonus feature, which I've seen done on other systems and always wanted to replicate in Domino. If not just to prove you can then because it's good to have.

The feature would allow you to reply - via email - directly to the blog. What I mean is - you would get an email saying "New reply to your post on codestore", which contains the text of the new reply and then, if you want to add a reply to it, you just hit reply and send an email to the magic reply-to address. The text is taken from your email and posted as a new comment. If the person you're replying to also wanted an email alert they'll get one and the conversation can continue like so.

Putting Theory in to Practice

Like most ideas I have I get excited about them and want to get on proving it can be done. I fell at the first hurdle though. It seems obvious to use a "When new mail arrives" agent, no? Well, I just can't get them to work.

What I've done so far is make this database (store.nsf) a Mail-in Database with its own email address. I then setup a simple "New mail" agent that adds a "Processed" field to the documents and saves them. I've sent the database some emails, which do arrive, but the agents just won't run.

It might be worth mentioning at this point that, in my ten years with Notes, I've never used this type of Agent before!

After a frustrating hour or two I Googled "new mail agents don't work" or something like that and finally found this technote, which says:

The signer of the agent (the last person to save or enable the agent) must have their mail file located on the same server as where the agent will run. The server determines this by taking the name of the last person to save the agent, performing a person lookup into the Domino Directory and retrieving the Mail Server from that user's Person document.

Why, why, why....!?

I'm not even sure that's the answer though. Although it could be, as the ID I signed it with is included in the FullName field of a Person document that does have a mail file on the same server, but the ID is from a different domain.

What I'm wondering is whether I should ditch this Agent trigger and just have it run every few minutes instead? Are new mail agents notoriously troublesome?

Comments

  1. Hi,

    Adding AMgr_DisableMailLookup=1 to the server notes.ini will disable the requirement to have the signers mailfile on the server where the agent is running.

    Furthermore I would suggest using a 'Before new mail arrives agent'.

      • avatar
      • Jake Howlett
      • Mon 19 Oct 2009 02:01 AM

      Thanks Almar. I'll give that a shot.

      Why would you suggest using the "before email" trigger?

      Show the rest of this thread

    • avatar
    • Fred Janssen
    • Mon 19 Oct 2009 03:12 AM

    I tend to create MailRobot id's (MailRobot Mail/Company, MailRobot Apps/Company) for all servers where agent are running on on the Before/After new mail arrives trigger.

    Works perfectly, just remeber tpo resign the agents when moving the db's to another server.

  2. An email option would be great, I really struggle to follow comments on mu comments.

    I have always found the before new mail arrives agents tricky to make releiable, even with the Notes ini setting above.

    There are also certain programatic restrictions which apply to those agents to stop them impacting performance. See the table in this article re folders

    http://lotus-blogs.blogspot.com/2007/08/all-about-pre-deliverybefore-new-mail.html

    A well written agent running every ten minutes is my preference

    • avatar
    • Richard Shergold
    • Mon 19 Oct 2009 03:30 AM

    Jake. I've just been through this whole nightmare myself with mail-after and mail-before agents on a customer's server that just would not behave. I just could not get the agent to run in a stable way over any more than about four days (and I tried the ini setting etc above). It kep switching itself off and going to sleep for no aparent reason (this is on a 6.5 server). Have now resorted to a good old run-every-5 minutes scheduled agent. Hopefully that will work. It seems ok so far. Richard

      • avatar
      • Jake Howlett
      • Mon 19 Oct 2009 03:46 AM

      As per yours and Sean's suggestion I am leaning towards just using a good old fashioned scheduled agent.

      It's not a time-critical operation. I'm sure you can all wait up to ten minutes to see an emailed reply appear.

      Show the rest of this thread

    • avatar
    • Richard Shergold
    • Mon 19 Oct 2009 03:34 AM

    p.s don't forget that the Run After Mail arrives is the TRIGGER for the agent and not the Target Documents it will run on (the first time your agent runs it will run on all docs that have ever been mailed into that database and in your code you need session.processeddocument(doc) or whatever it is to make sure that document is not processed again by that agent. But like I said, I've given up on the Before/After mail arrives agents and am going back to the scheduled method anyway.

  3. Why not just have the querysave do the work when a new comment is added by checking if someone has asked to be notified and sending right then?

      • avatar
      • Jake Howlett
      • Mon 19 Oct 2009 06:46 AM

      I think you've misunderstood the purpose of the agent Niall. The idea is that this database becomes a mail-in db and you can email your replies directly to the blog.

    • avatar
    • Tony Westwell
    • Mon 19 Oct 2009 07:11 AM

    I was told by an admin colleague that these triggers are triggered by the mail routing task on the server. I always have had problems with this trigger and now don't use it, also we used to go for the run ever 5 mins trigger in the agent and now that has had to be stopped as there were too many of these running on the server and taking up too much cpu time. We now use 'After documents are created or modified' as the trigger for these agents, as they only run if there is a new or modified document added to the database. Plus there is a standard 5 minutes wait in between the trigger and the actual running of the agent.

  4. I'm not in the business of Domino development anymore, but in the few years when I was working on it I always found it very confusing to try to figure out how to appropriately trigger agents, and to properly target them against the right documents. I feel your pain here.

    • avatar
    • Richard Hogan
    • Mon 19 Oct 2009 11:03 AM

    Hi Jake,

    I have to say that I've never had any trouble with these agents apart from, like yourself, having to originally spend hours figuring out that the mail file of the signer had to be on the same server as the db containnig the agent. On one customer site I had a new mail agent processing about 350 incoming mails per day without problems, and this worked for years first on R5 and then on R6.5.4. I still have agents handling lower volumes working in other db's without a problem.

    From memory some key things were:

    - using db.UnprocessedDocuments to get the collection of docs waiting to be processed

    - using session.UpdateProcessedDoc( doc ) to mark the doc as having been processed, so it doesn't show up in the UnprocessedDocuments collection the next time

    - Docs which have had the UpdateProcessedDoc treatment will still show up again in db.UnprocessedDocuments if they are modified later (so then you would need to rely on your own processed field)

    - db.UnprocessedDocuments, if I remember correctly, will only show docs that are received or modified since the agent was last saved, and it may look like the agent is not triggering. If you put the code for these agents into a script library then this issues doesn't arise as you will then rarely need to save the agent.

    • avatar
    • Niall Durkan
    • Mon 19 Oct 2009 12:10 PM

    Hi Jake, I see what you are saying. I have always had issues with the run after mail is received trigger and have opted for just a scheduled agent that looks for docs to process. While its not ideal (eg on most cases it has nothing to process) the agent exits if nothing to process so it doesn't take much time and its reliable.

  5. Ah, if only the internet had a unified system of commenting, we wouldn't even need to bother. :P

    • avatar
    • Ferdy
    • Mon 19 Oct 2009 03:10 PM

    I too would go for the scheduled agent. I don't trust any Domino agent other than direct or scheduled agents.

    • avatar
    • Terry Dixon
    • Mon 19 Oct 2009 11:38 PM

    We've attempted to use "after new mail has arrived" on many occassions with varied success and much frustration. We now always use a scheduled agent instead.

    • avatar
    • Patrick L
    • Tue 20 Oct 2009 04:21 AM

    I would like to defend mail agents, I have had a 'before mail arrives' agent running on production apps for many years with no problems. However the difference is that they are Notes formula agents. IIRC formula agents also do not have the restrictions on where the signer has their mail file.

    • avatar
    • Pamela Beaudoin
    • Tue 20 Oct 2009 11:27 AM

    I agree with Patrick L. If you are using formula only, these agents work like a charm. Usually I use before mail arrives and that seems to do the trick.

    If you can't achieve what you need using formula, a scheduled agent might be the trick. You can do a fair amount using formula these days, although it is clunky, I agree.

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Mon 19 Oct 2009

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content