Click here to Skip to main content
15,879,535 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Calculations Help! Pin
Member 107286676-Apr-14 8:50
Member 107286676-Apr-14 8:50 
GeneralRe: Calculations Help! Pin
Mycroft Holmes6-Apr-14 12:55
professionalMycroft Holmes6-Apr-14 12:55 
GeneralRe: Calculations Help! Pin
Eddy Vluggen7-Apr-14 7:46
professionalEddy Vluggen7-Apr-14 7:46 
AnswerRe: Calculations Help! Pin
ZurdoDev7-Apr-14 8:46
professionalZurdoDev7-Apr-14 8:46 
QuestionRefresh Devexpress Master-Detail gridcontrol Pin
dilkonika5-Apr-14 6:04
dilkonika5-Apr-14 6:04 
QuestionFree Twain for .NET Pin
dilkonika4-Apr-14 11:36
dilkonika4-Apr-14 11:36 
AnswerRe: Free Twain for .NET Pin
Richard MacCutchan4-Apr-14 23:21
mveRichard MacCutchan4-Apr-14 23:21 
QuestionAdd Multiple Records to one TextBox from SQL Pin
Dan O'Riordan2-Apr-14 23:52
Dan O'Riordan2-Apr-14 23:52 
Hi guys,

I have the following code that will send an email from Visual Basic project using data from an SQL row called "Email". It works fine. However, it appears it is only showing one email from SQL into the TextBox. Therefore, only sending it to one email address. I have two email addresses stored in the database for testing but only one of them get the email message.

Here is the code:

VB
 'Connect to SQL Server database and query out only Address column to fill into DataTable

  Dim con As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=FigClubs;Integrated Security=True;Pooling=False")

  Dim cmd As SqlCommand = New SqlCommand("SELECT Email FROM Members", con)

  con.Open()

  Dim myDA As SqlDataAdapter = New SqlDataAdapter(cmd)

  Dim myDataTable As DataTable = New DataTable

  myDA.Fill(myDataTable)

  con.Close()

  con = Nothing



Try
      Dim Smtp_Server As New SmtpClient
      Dim e_mail As New MailMessage()
      Smtp_Server.UseDefaultCredentials = False
      Smtp_Server.Credentials = New Net.NetworkCredential(My.Settings.ClubEmail, My.Settings.EmailPassword)
      Smtp_Server.Port = 587
      Smtp_Server.EnableSsl = True
      Smtp_Server.Host = "smtp.gmail.com"

      e_mail = New MailMessage()
      e_mail.From = New MailAddress(TextBox4.Text)
      e_mail.To.Add(EmailTextBox.Text)
      e_mail.Subject = TextBox1.Text
      e_mail.IsBodyHtml = False
      e_mail.Body = TextBox2.Text
      Smtp_Server.Send(e_mail)
      MsgBox("Your email has been sent.")

  Catch error_t As Exception
      MsgBox(error_t.ToString)
  End Try
  Me.Close()


Any help you can provide with this would be greatly appreciated.

Thanks,
Dan
AnswerRe: Add Multiple Records to one TextBox from SQL Pin
Richard MacCutchan3-Apr-14 0:07
mveRichard MacCutchan3-Apr-14 0:07 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Dan O'Riordan3-Apr-14 0:15
Dan O'Riordan3-Apr-14 0:15 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Richard MacCutchan3-Apr-14 0:22
mveRichard MacCutchan3-Apr-14 0:22 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Dan O'Riordan3-Apr-14 0:26
Dan O'Riordan3-Apr-14 0:26 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Richard MacCutchan3-Apr-14 0:31
mveRichard MacCutchan3-Apr-14 0:31 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Dan O'Riordan3-Apr-14 0:38
Dan O'Riordan3-Apr-14 0:38 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Richard Deeming3-Apr-14 0:55
mveRichard Deeming3-Apr-14 0:55 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Dan O'Riordan3-Apr-14 1:03
Dan O'Riordan3-Apr-14 1:03 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Richard Deeming3-Apr-14 1:14
mveRichard Deeming3-Apr-14 1:14 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Dan O'Riordan3-Apr-14 1:23
Dan O'Riordan3-Apr-14 1:23 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Richard MacCutchan3-Apr-14 1:12
mveRichard MacCutchan3-Apr-14 1:12 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Dave Kreskowiak3-Apr-14 2:24
mveDave Kreskowiak3-Apr-14 2:24 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Dan O'Riordan3-Apr-14 2:43
Dan O'Riordan3-Apr-14 2:43 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Dave Kreskowiak3-Apr-14 3:43
mveDave Kreskowiak3-Apr-14 3:43 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Richard MacCutchan3-Apr-14 4:00
mveRichard MacCutchan3-Apr-14 4:00 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Dan O'Riordan3-Apr-14 2:52
Dan O'Riordan3-Apr-14 2:52 
GeneralRe: Add Multiple Records to one TextBox from SQL Pin
Richard MacCutchan3-Apr-14 3:11
mveRichard MacCutchan3-Apr-14 3:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.