private void bt_Send_Click(object sender, EventArgs e) { try { string signature = comboBoxSignature.Text; string subject = textBoxSubjectMail.Text; // Initialize what we need to send mails string emailFrom = ""; string message = textBoxTextMail.Text; if (!string.IsNullOrWhiteSpace(subject) && !string.IsNullOrWhiteSpace(message)) { try { signature = connectionDB.getSignature(connectionDB.getUserId(comboBoxSignature.Text)); //get signature } catch { signature = ""; } if (!string.IsNullOrWhiteSpace(signature)) { int nbRows = dataGridViewList.RowCount; progressBarSendingMail.Maximum = nbRows - 1; progressBarSendingMail.Step = 1; // Initialize the progressBar progressBarSendingMail.Value = 0; progressBarSendingMail.Visible = true; for (int row = 0; row < nbRows - 1; row++) { SendMails sendmail = new SendMails(); sendmail.sendAMail(message, emailFrom, dataGridViewList.Rows[row].Cells[1].Value.ToString(), subject, signature, allAttachments, progressBarSendingMail); //Sending mail and updating progressBar } allAttachments.Clear(); textBoxBrowse.Text = null; pictureBoxCancelBrowse.Visible = false; } else { MessageBox.Show("Signature is empty or is wrong", "Warning : email empty", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { if (string.IsNullOrWhiteSpace(message)) { MessageBox.Show("Email is empty, please write a message.", "Warning : email empty", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("subject is empty, please write a subject.", "Warning : subject empty", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } catch (Exception er) { MessageBox.Show(er.ToString()); } }
private void comboBoxName_SelectedIndexChanged(object sender, EventArgs e) { checkBoxDefaultSignature.Checked = false; string sqlQuery = "SELECT signature FROM user WHERE name ='" + comboBoxName.Text + "'"; // Put infos in textboxes connectionDB.PutQueryIntoTextBox(sqlQuery, textBoxSignature, "signature"); sqlQuery = "SELECT id FROM user WHERE name = '" + comboBoxName.Text + "'"; idUser = connectionDB.getUserId(comboBoxName.Text); // Get the id of the user (in order to update later) if (comboBoxName.Text == Properties.Settings.Default.Signature) { checkBoxDefaultSignature.Checked = true; } }