我正在开展一个项目,管理员希望通过电子邮件将网站更新发送给网站上的所有注册用户。如何做到这一点。 我正在使用asp.net和vb
Dim em As MailMessage = New MailMessage("xxx@xxx.com", user email adress)
em.Subject = "Updates"
em.IsBodyHtml = True
em.Body = txtNews.Text
Dim mailClient As New SmtpClient("localhost")
Dim basicAuthenticationInfo As System.Net.NetworkCredential = New System.Net.NetworkCredential("xxx@xxx.com", "xxx@com")
mailClient.UseDefaultCredentials = False
mailClient.DeliveryMethod = SmtpDeliveryMethod.Network
mailClient.Credentials = basicAuthenticationInfo
mailClient.Send(em)
这是我用来发送1封电子邮件的后端代码。如何使用它来批量发送电子邮件?
答案 0 :(得分:2)
使用To
或Bcc
属性 - 这些是MailAddress
的集合。
mailClient.To.Add(mailAddress1)
mailClient.Bcc.Add(mailAddress1)
或者:
mailClient.To.Add(New MailAddress("my@example.com"))
mailClient.Bcc.Add(New MailAddress("my@example.com"))
答案 1 :(得分:2)
MailAddress To = new MailAddress(aryEmail[i], FromAddressTitle, System.Text.Encoding.UTF8);
mailClient.Bcc.Add(To);