Writing the Mail Address of All People in the ListBox to the TextBox

  • Thread starter Thread starter MuhammedSahin
  • Start date Start date
M

MuhammedSahin

Guest
I am developing a project with Windows Form. I have 2 ListBoxes. I'm putting contacts from ListBox1 to ListBox2. Later, I want to print the e-mail addresses of the people I sent to Listbox2 (for example, I sent 5 people) to texbox. I will use these e-mail addresses to send mail last.

When I press the save button of the form, I first want to call the method that I pulled the mails from textbox, and then immediately send mail to the items in the textbox.

My question is that I can write the e-mail addresses of the people in the listbox2 to texbox. Here is my sample code snippet.


public void mailDenetciAdresleriGetir()
{
connection2.Open();

SqlCommand komut = new SqlCommand("SELECT EMAIL FROM PERSONELLER WHERE [AD]+' '+[SOYAD] LIKE '" + listBoxDenetlenecekPersonel.Text + "'", connection2);
SqlDataReader read = komut.ExecuteReader();
while (read.Read())
{
if(textBox1.Text =="")
{
textBox1.Text =(read["EMAIL"].ToString());
}else{
textBox1.Text += ";" + (read["EMAIL"].ToString());
}




}

connection2.Close();
}

Continue reading...
 
Back
Top