Click here to Skip to main content
15,913,055 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
please give me some code to handle exceptions while sending mail using System.net.mail...
Posted

1 solution

try
{
//send mail
}
catch
{
MessageBox.Show("Could not send mail");
}

You can also choose to catch specific exception types, but what you do when they happen, is really up to you.
 
Share this answer
 
Comments
Member 7962316 30-Jun-11 3:35am    
i want to handle the following exceptions SmtpFailedRecipientException,SmtpException

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900