1

I am working on a project in which admin wants to send updates of website via email to all registered users on web site.How to do this.? I am using asp.net and 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)

This is the backend code i am using for sending 1 email.How can i use this to send emails in bulk?

chetan p
  • 57
  • 9

2 Answers2

2

Use the To or Bcc properties - these are collections of MailAddress.

mailClient.To.Add(mailAddress1)
mailClient.Bcc.Add(mailAddress1)

Or:

mailClient.To.Add(New MailAddress("my@example.com"))
mailClient.Bcc.Add(New MailAddress("my@example.com"))
Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • i m new to asp.net plz tell how can i get the email ids of users from database n send them email one by one.. How to store all email ids n retrieve them one by one..? – chetan p Dec 13 '11 at 16:54
  • @chetanp - Why don't you ask another question? – Oded Dec 13 '11 at 17:59
  • ok :D should i send thousands of emails together or in batch of hundreds and how to do that? – chetan p Dec 14 '11 at 11:40
  • @chetanp - You don't. Ask your ISP about bulk email options. If you do it yourself you can easily end up getting your domain blacklisted as a spammer domain. – Oded Dec 14 '11 at 11:41
2
  MailAddress To = new MailAddress(aryEmail[i], FromAddressTitle, System.Text.Encoding.UTF8);
  mailClient.Bcc.Add(To);
Masoomian
  • 740
  • 1
  • 10
  • 25
  • which file to import for 'To' – chetan p Dec 13 '11 at 11:15
  • i think you should attach file to your message. 'To' is only MailAddress . http://stackoverflow.com/questions/1195111/c-sharp-mailto-with-attachment – Masoomian Dec 13 '11 at 11:26
  • i m new to asp.net plz tell how can i get the email ids of users from database n send them email one by one.. How to store all email ids n retrieve them one by one..? – chetan p Dec 13 '11 at 16:50