• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 768
  • Last Modified:

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
0
RichardStarkey
Asked:
RichardStarkey
1 Solution
 
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
 
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now