Asp.net Email receive problem

戏子无情 提交于 2020-01-25 13:10:09

问题


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.



来源:https://stackoverflow.com/questions/3369251/asp-net-email-receive-problem

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!