Problems with Mail Agent


Morning,
I've a problem with my mail agents.  When a document is created is is sent around an approval workflow.  After the final approval a mail is sent back to the originator of the document to let them know things are complete.  Due to heavy use of local replication at my company all mails are sent by an agent at the end of the day

The problem happens if a person leaves the company.  The agent tries to send a mail to the person but they are no longer there so the mail agent cannot find the sender.  This causes the agent to stop running.  All further mails are not sent and every time the agent runs thereafter it hits this document and does not run.

how can I either put a check in to make sure the name exists and, ideally, ignore the problem so the agent continues on the other documents?

Thanks,
Richard
RichardStarkeyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sjef BosmanGroupware ConsultantCommented:
Use some error checking around the statements sending the mail:

    On Error Goto notsent
    Call maildoc.Send(False)
    ...
    Exit Sub

notsent:
    ' do something useful here, to prevent the document will be handled again and again
    doc.status= "ERROR: Can't send!!"
    Call doc.Save(True,False)
    Resume somewhere ' need a label here

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mbonaciCommented:
Hi RichardStarkey,
You can just put this on top of your agent's code:

    'To avoid the agent stop on error "Unable to send mail, no match found in Name and Address book(s)":
    On Error 4294 Resume Next  

the agent will simply resume with sending next document if this kind of error happens.

Hope this helps,
Marko
0
marilyngCommented:
Agreed, but I would do a sub to do an actual lookup of the name (see the mail file processing script library), and if not found, create a newsletter to send to some default person or group so the documents don't go unprocessed.

Also, question, how are the names configured for these notifications?  
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

RichardStarkeyAuthor Commented:

Thanks for the suggestions.
Can I just do the following.

***********************
Do While Not doc Is Nothing
      'and send the mail message
      On Error Goto NotSent
      Call maildoc.Send( False )
      doc.MailFlag = ""
      Call doc.Save(False, False)

NextDocument:
      Set doc = doc1

Loop

NotSent:
     Resume NextDocument

***********************

So the documents causing the error are just ignored?  I'm not sure how to use the Resume statement but that's all I want.  Just skip the doucment in question so that it remains in the view (doesn't have the mailflag cleared).

0
Sjef BosmanGroupware ConsultantCommented:
Yes you could, but...
- you won't know what document caused an error (or is that the mailflag??)
- the error-document would be processed again and again
- all other errors would be also caught and skipped

Suggested change:
    Do While Not doc Is Nothing

          Set doc1= ....  ' I suppose...?

          'and send the mail message
          On Error Goto NotSent
          Call maildoc.Send( False )
          doc.MailFlag = ""
          Call doc.Save(False, False)

    NextDocument:
          On Error Goto 0 ' <---- reset error handling
          Set doc = doc1
    Loop

    NotSent:
         ...  ' you could do something with the error-document here, e.g. a NewsLetter as Marilyn suggests, or
         doc.MailFlag= "ERROR"
         Call doc.Save(...)
         Resume NextDocument

The addition of these last lines could help you with the view you have to run the agent with. In the SELECT, you could add
    & MailFlag!="ERROR"
so the error-documents would be skipped the next time.
0
RichardStarkeyAuthor Commented:

Hi Sjef,
Since the mailing agent runs against a view every night then I see no problem leaving the error causing documents in teh view.  I am only talking about 50 documents a night so it should not really impact too much on the processing time.

People should be noticing within 24-48 hours if they have not had mail notification on a document anyway and they are already trained to go into that view to look at the mail status of their documents.
Thanks for your help
Richard
0
RichardStarkeyAuthor Commented:

Actually Sjef, looking at it you are right.  It makes much more sense to at least change the mail flag so I can make sure that the error processing is working.

Not sure what the OnError Goto 0 is for though?
0
Sjef BosmanGroupware ConsultantCommented:
> On Error Goto 0
This will reset errorhandling to the default action, i.e. stop processing with normal exit. I make it a habit to let the software crash as it should on errors except at the places where I want to catch them.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.