System.Net.Mail execptions

Started by mathia, February 12, 2014, 10:30:17 AM

Previous topic - Next topic

mathia

I am able to send an email using System.Net.Mail.  I would like to be able to use SmtpFailedRecipientsException in case there is a problem sending to a specific address.  I, however, don't have a clue how to get that part to work.  I can instantiate the object, but get errors trying to access any of the properties.  I am testing with a known bad email address.  How does one handle exceptions in .Net code using Winbatch?

Deana

You can trap errors in WinBatch using IntControl 73. The "additional error information" (in the case of CLR the exception) can be obtained using the wberroradditionalinfo variable defined when an error occurs. For more about error handling in WinBatch please read:  http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+Tutorials+Trap~Errors.txt

Unfortunately an exception doesn't get thrown in the case of a bad recipient, I have not figured out a way to capture that.
Deana F.
Technical Support
Wilson WindowWare Inc.

td

The very first line of the MSFT documentation for the SmtpFailedRecipientsException class states, "This API supports the .NET Framework infrastructure and is not intended to be used directly from your code."  This basically means that the class is not something that you should be trying to create in your script.

Normally, CLR exceptions are presented via the "More Error Info" box you see when WinBatch displays an error or through the wberroradditionalinfo variable as describe above when you implement your own error handling.

In this case, the CLR is not percolating the exception or any kind of error for that matter back up to WinBatch. This is either a bug in the FCL class or the documentation is incorrect and unfortunately, there isn't much that can be done to correct the problem. 

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

mathia

I have used that before.  Just thought that I might get some use out of some of the new .Net toys.

Thanks.