You'll need a try/catch in the calling routine, then throw the errors in SendEmails.
>Unfortunately this is legacy data that I'm working with so there was no validation when it was being entered. To catch the bad addresses, what I do is this:
>
>
try
> {
> msg.To.Add(email.eml_email);
> }
> catch (Exception)
> {
> badEmails += cus.cus_number + " - " + email.eml_email + ", ";
> }
>
>I agree, the design is not the best. It was written in a rush while trying to get a working solution to meet a deadline (and of course things getting added in to the specs during the development), hence why I am trying to refactor it now.
>
>The method is actually SendEmails (plural) so it is meant to send all the emails. So if I break it down to a method that does one thing, send an email. How do I trap an error if there is an error sending it and report it back to the calling method?
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer