We help IT Professionals succeed at work.

Agent for autoforwarding mails in lotus notes

Glactus asked
Medium Priority
Last Modified: 2013-12-18
There's a requirement of autoforwarding of mails from one notes mailing database to some external mail address when a new mails comes in mailing database.

I have created an agent for this which is forwarding new mails.

Dim db As NotesDatabase
Dim Maildoc As NotesDocument
Set db=session.currentDatabase
Dim doccoll As NotesDocumentCollection
Set doccoll=db.unprocessedDocuments
Dim forwardDoc As NotesDocument
Dim a As Integer
Print "agent started runing"
Print "agent runnning for " doccoll.count " documents"
    For a=1 To doccoll.count
        Set forwardDoc=doccoll.GetNthDocument(a)
        Set Maildoc = New NotesDocument( db )
      Call forwardDoc.CopyAllItems( Maildoc, True )
      Maildoc.Principal = forwardDoc.From(0)
      Maildoc.SendTo ="xyz@gmail.com"
      'Call maildoc.Save(True,True)
      Call Maildoc.Send(True)
      Print a

Exit subs

Agent is trigered on event "when a new mail has arrived"

But agent is only running for one time .
means intaily when database has no mails i have pasted some documents in it.
it works for one time .
After this again i have pasted some document .So the agent should run but its not working?
Watch Question

on the server console you can type "tell amgr sched" and see if agent is registered in agent manager with the appropriate action.
V M  [agent name] [Path to agent]

Also is the agent should provide log of when agent last run against x number of documents.
I believe if the agent is set to after new mail  then it is kicked off by the router process, so after initial run copying documents into the database will not trigger it, it should be mailed to the database so that router tasks detects it.
Possibly somone can confirm/refute that.

Alternative is to use event when documents ceated or modified and create a flag field in documents that are forwarded.
Sjef BosmanGroupware Consultant

Is mail received directly into this mail database, or in a replica?

Check the server's log .nsf database, Miscellaneous section, where the agent might have left you an error message.

If you would like to have a copy of the mail delivered to the mail file as well in addition to having it forwarded, than the best solution is to simply create a mail file rule for "Send copy to" - you probably need an 8 + mail template to have this rule available.

If you would like to forward the mails without having a copy in the mail file, than use the forwarding email address field in the person document / mail-in document.

The agent is not a recommended solution.
Pasting mail documents into a database does NOT trigger "after new mail has arrived" agents. Such agents are ONLY triggered when the router task _delivers_ mail to the database.

If you want your agent to be triggered when you paste mail documents into the database, then you need to specify its trigger as "after documents are created or modified" (but be aware of the few minutes of delay until your agent runs after you pasted documents).


The agent started working, I dont know I diid nothing but it started working automatically.
Sjef BosmanGroupware Consultant

Brilliant! Does nothing and it works! There must be many companies that are desperately looking for a magician like you as Administrator...  ;-))
Unlock this solution and get a sample of our free trial.
(No credit card required)
Sjef BosmanGroupware Consultant

Very plausible explanation.


I've requested that this question be closed as follows:

Accepted answer: 0 points for Glactus's comment http:/Q_26964453.html#35963892

for the following reason:

The agent started working, I dont know I diid nothing but it started working automatically.
See my explanation in Comment ID 35964620.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.