I have a routine that is supposed to grab all email addresses within a certain group. The email address list can be well over 1000 emails. When emailing it out though I can only send around 150 emails at a time. So what I i've done is executed a query and threw all the emails into a collection.
How do I now reiterate through the collection grab 100 addresses each time and call the routine to email that group?
Dim emailToGroup As String = ddlEmailTo.SelectedValue
Dim connStr As String = ConfigurationManager.ConnectionStrings("SNA_TRT").ConnectionString
Dim sqlConn As SqlConnection
sqlConn = New SqlConnection(connStr)
sqlConn.Open()
Dim strSQLgetEmails As String = "SELECT C.contact_email as Company FROM cust_emerg_contacts E INNER JOIN TRT_parent_accounts A ON E.CompID = A.CompID INNER JOIN MRT_customer_contacts C ON E.ContactID = C.id WHERE (A.CARE_LEVEL LIKE '" & emailToGroup & "') AND (A.[Status] = 'Active')"
Dim cmd As New SqlCommand(strSQLgetEmails, sqlConn)
Dim dr As SqlDataReader = cmd.ExecuteReader()
Dim EmailCol As New Collection
Dim count As Integer = 0
While dr.Read
EmailCol.Add(count, dr(0))
count &= 1
End While
dr.Close()
sqlConn.Close()
'Grab 100 emails stuff into a string (toEmailList) and send the message. Grab Next 100 and send message.. ect. ect
'SendMail(tbEmailFrom.Text, ToEmailList, tbEmailSubject, tbMessageBody)