View Single Post
  #2 (permalink)  
Old May 30th, 2013, 02:25 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Tulsi,

Take a look at page 660 for a concrete example. That code catches an SmtpException as well as a generic Exception. You could further divide this by catching SmtpFailedRecipientException and SmtpFailedRecipientsException:

http://msdn.microsoft.com/en-us/libr...exception.aspx

To find out the Exceptions that can be thrown, consult the MSDN documentation. Here's an example of the Send method of the SmtpClient class: http://msdn.microsoft.com/en-us/library/swas0fwc.aspx

In this case, I would probably just handle SmtpException as all you want to do is tell the user something went wrong while sending the message. The first three exceptions can typically be avoided by constructing a valid message object.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!