Asp.net Email receive problem

2019-08-17 13:28发布

问题:

I'm using MailMessage class and then sent mail to many recipients. My code is here.

MailMessage msg = new MailMessage();

SmtpClient client = new SmtpClient("smtp.mysite.com");
client.EnableSsl = false;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("myusername@mysite.com", "mypassword");
forea(User u in users)
{
  msg.To.Add(u.Email);
}

client.Send(msg);

This work successfully.

But problem is all email shown on the recipient computer. TO: user1.fds.com;email2.fdsa.com;email3.fdsa.com;... etc.

I need to show only current user email. How to do it?

Maybe i will do it like this

forea(User u in users)
{
  msg.To.Clear();
  msg.To.Add(u.Email);
  client.Send(msg);
}

But it is too slowly.

回答1:

One option is to use MailMessage.Bcc instead of To. That won't show the recipient in the "To" line of course, but usually that's not a problem.

I do hope the "many recipients" genuinely want this mail...



回答2:

I would suggest that you iterate over the list of recipients and send the emails one at a time.

Using BCC may cause the mail to be classed as spam.