Mahmoud Samy
Mahmoud Samy

Reputation: 2852

SmtpClient sends any email twice

When I send an email using SmtpClient I found a strange behavior:

  1. It took too long to be delivered.
  2. It's delivered twice.

SmtpClient client = new SmtpClient();
client.Host = "smtpout.secureserver.net";
client.Port = 80;
client.Timeout = 10000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(_fromAddress, _password);
MailMessage message = new MailMessage();
message.Body = _body;
message.BodyEncoding = Encoding.UTF8;
message.IsBodyHtml = true;
message.Subject = _subject;
message.To.Add(_toAddress);
message.Bcc.Add(_bccAddress);
message.From = new MailAddress(_fromAddress);
client.Send(message);

Update 1:

I'm sure that TO and BCC are different, and client.Send(message); is called only once.


Update 2:

After a lot of debugging I got the following:


Update 3:

Upvotes: 3

Views: 2886

Answers (1)

msporek
msporek

Reputation: 1197

The most obvious answer is that the _toAddress and _bccAddress are the same, or maybe the mailbox address where you send a BCC is redirected to the other address?

Verify under debugger that you do not run the code twice by mistake, this is also possibe.

Based on the code sample it's not possible that it sends the email twice.

Upvotes: 3

Related Questions