We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to find undeliverd emails?

Hi,
I in my desktop application i am using this code for sending emails:
MailMessage template = CreateMessage();
SmtpClient smtpClient = new SmtpClient(General.SmtpServN, General.SmtpPort);
smtpClient.Username = General.SmtpUN;
smtpClient.Password = General.SmtpPass;
SmtpClientBulkSendAgent bulkAgent = new SmtpClientBulkSendAgent(smtpClient);
bulkAgent.AddMessage(template);
bulkAgent.Start();

private MailMessage CreateMessage()
{
MailMessage msg = new MailMessage();

msg.From = new MailAddress("saj@yahoo.com");

msg.ReplyTo = new MailAddress("sajeesh@yahoo.com");
msg.To.Add(new MailAddress("sajeesh@gmail.com");

msg.Subject =“test mail”

msg.HtmlBody = General.MsgHtmlBody; // passing variable,


msg.Date = DateTime.Now;

return msg;
}
By using this code, if I sent mails to ID’s that are not existing the process is working with out any error,
How can i know whether it is delivered or not?
Can you please send me the code for catching undelivered mail id’s?
Regards,
Sajeesh,

Hi Sajeesh,

You can use SmtpClientBulkSendAgent.FailedDeliveryMessages property to get all the messages which are un-delivered.

foreach (MailMessage message in bulkAgent.FailedDeliveryMessages)

{

Console.WriteLine(message.To.ToString());

}

Attached is a demo program that sends out bulk emails. If you stop the process before all the emails are delivered, it will show the undelivered email addresses in the textbox. You can use 2 or more comma-separated email addresses and stop it after just 1 second to view the undelivered emails.