Unanswered: Test MAPI Connection (Definitive Description)
(Isn't this fun? Type MAPI and SQL into Google and it almost tilts!)
Here is the situation:
1- When SQL Agent starts, it establishes a MAPI session. For some bizarre design reason, it keeps that session open as long as it is running, rather than re-opening the session when it has mail to send. (this can be days, weeks, or months)
2- Frequently, Exchange servers are clustered. When the virtual server moves to a different physical server in the cluster, - or the Exchange server is restarted for whatever reason - the (above) MAPI session of the SQL Agent gets jammed.
3- SQL Agent tries, and fails to send an E-mail saying (for instance) that a database dump has completed (etc.)
4- User posts a question to some forum, asking for help again.
My solution: I created a job to run on a daily basis to restart the SQL Agent, and re-establish the MAPI session. Voila!
The problem: Now we (sometimes) get the message:
 Startup error: Unable to initialize error reporting system (reason: The EventLog service has not been started)
This is incorrect - the service was never stopped!
*sigh* No hits in Microsoft or Google - Back to the drawing board.
SO: Can anyone think of a way to *test* the MAPI connection in a job step (without actually sending a message), so that the agent restart job is only executed if the MAPI connection is failing?
Hi - Thanks, that is pretty much but what I am doing, except that you have to "detach" the process. Else when the SQL Agent stops, it terminates all associated jobs and the NET START never gets a chance to execute!
So I actually go out to a command shell and use the START command, which detaches the rest of the job.
The real problem is that this results (sometimes) in the 'event log' error message I posted above. What I would like to do is only run this command if the MAPI connection is down - so I need a way to test the MAPI without sending an e-mail...