0 votes
by (140 points)

Hi ,
Went through your study material and found two ways to get list of rejected recipients,if any when email is sent using Rebex Smtp.

1) Using Rebex.Net.Smtp.SendDirect() ;

            SmtpRejectedRecipient[] rejected = Rebex.Net.Smtp.SendDirect(MailMessage);
            MessageBox.Show("Rejected Recipients count: " + rejected.Count());

2) Using RejectedRecipient event

            smtpObject.RejectedRecipient += smtpObject_RejectedRecipient;
            smtpObject.Send(MailMessage );

            private void smtpObject_RejectedRecipient(object sender, SmtpRejectedRecipientEventArgs e)
            {

            }

Did implement both with rebex latest dlls. Could not get rejected recipients list. Does rebex Smtp support giving list of rejected recipients?

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (148k points)

Yes, both of these methods provide a list of rejected receipients - if one or more recipients have actually been rejected by the SMTP server.

Testing this is quite simple:

mail.From = "bob@example.org";
mail.To = "does.not.exist.10485720948034@gmail.com";
mail.Subject = "Sample subject";
mail.BodyText = "Sample text.";

SmtpRejectedRecipient[] rejected = Smtp.SendDirect(mail);
foreach (var recipient in rejected)
{
    Console.WriteLine("Rejected '{0}':\n{1}\n", recipient.Address, recipient.Response.Raw);
}
...