Ideally, the libraries you're using will come with documentation that will list all of the types of exceptions that can be thrown, if not then you'll have to use a tool like Reflector to inspect the methods you're using to find their thrown exceptions.
For example, the SmtpClient.Send
method (as documented here http://msdn.microsoft.com/en-us/library/swas0fwc.aspx ) lists these exceptions:
- ArgumentNullException
- InvalidOperationException
- ObjectDisposedException
- SmtpException
- SmtpFailedRecipientsException
Remember to catch exceptions in descending order of derivity, i.e. catch SmtpFailedRecipientsException
before SmtpException
because SmtpFailedRecipientsException
derives from SmtpException
.