转换数据库到VB中的一个列表。 我基本上是用2所列出的第一个列表中包含多个电子邮件地址,或他们像EXMPLE极“@ hotmail.com”第二个列表是从,我已经链接到形式的数据库中的列读取。 我会后我试图使工作的代码,但它似乎并没有被考虑到。 这是假设作为与选项的警报系统发送到数据库中的1人或所有人,请帮助,使这项工作?
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim Smtp_Server As New SmtpClient
Dim e_mail As New MailMessage()
Dim self As New MailAddress("archernolan151@gmail.com")
Dim strCarriers As New List(Of String) '@nd half of carriers email
Dim Scall As New List(Of String) 'List from the linked Column
Smtp_Server.UseDefaultCredentials = False
Smtp_Server.Credentials = New Net.NetworkCredential("blank@gmail.com", "password")
Smtp_Server.Port = 587
Smtp_Server.EnableSsl = True
Smtp_Server.Host = "smtp.gmail.com"
strCarriers.Add("@pm.sprint.com")
strCarriers.Add("@vtext.com")
strCarriers.Add("@tmomail.net")
strCarriers.Add("@txt.att.net")
rw = ContactsDataSet.Tables(0).NewRow 'Database Columns
rw.Item("Call") = Scall
ContactsDataSet.Tables(0).Rows.Add(rw) 'End of database
If rad1.Checked = True Then 'If the radio button is clicked it will take the data from the Database verses from the text box
For Each item In Scall
For Each Carrier As String In strCarriers
e_mail = New MailMessage()
e_mail.From = self
e_mail.To.Add("item" + "Carrier")
e_mail.Subject = txtSubject.Text
e_mail.IsBodyHtml = False
e_mail.Body = txtMessage.Text
Smtp_Server.Send(e_mail)
Next Carrier
Next
ElseIf rad1.Checked = False Then
For Each Carrier As String In strCarriers
e_mail = New MailMessage()
e_mail.From = self
e_mail.To.Add(txtTo.Text + Carrier)
e_mail.Subject = txtSubject.Text
e_mail.IsBodyHtml = False
e_mail.Body = txtMessage.Text
Smtp_Server.Send(e_mail)
Next
End If
MsgBox("Mail Sent")
Catch error_t As Exception
MsgBox(error_t.ToString)
End Try
End Sub