tags:

views:

29

answers:

1

I am using SmtpClient (.NET 3.5, VS 2008) for mass mailings. The code below starts with about 2 seconds per send and deteriorates to more than 20 seconds per send after the foreach loop has processed about 30 addresses and proceeds to deteriorate. Any ideas?

Jim

// Setup Client
SmtpClient client = new SmtpClient(smtpHost, 587);
client.Credentials = new NetworkCredential(smptLogin, smtpPassword);

// Send mail
foreach (string address in addresses)
{
    MailMessage message = BuildMessage(body);
    message.To.Clear();
    message.To.Add(new MailAddress(address));

    client.Send(message);
}
+3  A: 

The provider running the host you're connecting to might be implementing throttling as an anti-spam measure.

It looks like the content of your mail doesn't change per-recipient. In an enterprise environment, I would send a single mail, not dozens, and add recipients to the Bcc list. You might try this.

Michael Petrotta