Link to home
Start Free TrialLog in
Avatar of Glactus
Glactus

asked on

Agent for autoforwarding mails in lotus notes

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"
      Maildoc.copyTo=""
      Maildoc.BlindCopyTo=""
      'Call maildoc.Save(True,True)
      Call Maildoc.Send(True)
      Print a
      Next

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?
Avatar of doninja
doninja
Flag of United Kingdom of Great Britain and Northern Ireland image

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

ASKER

The agent started working, I dont know I diid nothing but it started working automatically.
Brilliant! Does nothing and it works! There must be many companies that are desperately looking for a magician like you as Administrator...  ;-))
ASKER CERTIFIED SOLUTION
Avatar of wuesten_fuchs
wuesten_fuchs
Flag of Germany 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
Very plausible explanation.
Avatar of Glactus

ASKER

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.