Click here to Skip to main content
15,909,039 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am sending mail using
System.Net.Mail;
. I want to catch exception in case of Recipients email id invalid or not available. I my code "SmtpFailedRecipientsException" is not throwing exception in any case.
What is exact use of
SmtpFailedRecipientsException
. How can I identify that "ToEmail" is invalid/not available. Please help.

What I have tried:

using(Smtp client = new SmtpClient())
{
try{
client.Send(message);
}
catch(SmtpFailedRecipientsException ex)
throw ex;
}
Posted
Updated 3-Apr-18 0:26am

1 solution

You can't tell if it's not valid. If it's in the wrong format then it will throw an exception when you add it as a recipient, but if the email address is in the right format but not a valid recipient then it's impossible to know at that point in the code. Some of this does depend a little on the target smtp server, but in general you can't know if an email address is valid.
 
Share this answer
 
Comments
Member 9579525 3-Apr-18 7:23am    
Thanks.
Member 9579525 5-Apr-18 1:30am    
Can we pull sender's inbox to identify which mail delivery has failed?
F-ES Sitecore 5-Apr-18 4:34am    
Yes, that's a common way to deal with this.
Member 9579525 5-Apr-18 5:00am    
ok. Thanks. I googled around that.Got solution as use pop3client. I dont knw about it. Can u share something about this. Which dll is to usee for this.
F-ES Sitecore 5-Apr-18 5:02am    
There's no built-in .net classes that can use pop3 so you're going to have to google for one someone else has written and pick one you like (edit: or learn pop3 and write your own :) )

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