Note that there are some explanatory texts on larger screens.

plurals
  1. POc# sending mail from window form not triggering
    text
    copied!<p>I'm having some wierd behaviour in my WinForm application coded in c#.</p> <p>in my: <code>private void buttonSave_Click(object sender, EventArgs e)</code></p> <p>Im calling my function: <code>functions.sendStatusEmail();</code></p> <p>The weird thing is that, when I press the <kbd>Save</kbd> button then email send is not triggered. But if I close my application the mail is handle and sent.</p> <p>Have I missed something or do one need to trigger som application event manually to have run the sendout.</p> <p>( I tried using <code>client.SendAsync(mail,null);</code> then it triggerd at click but the mail was empty)</p> <p>Thanks in advance</p> <p>-- Edit: code expamples</p> <pre><code>private void buttonSave_Click(object sender, EventArgs e) { // checks if a ticket is active if (workingTicketId &gt; 0) { // update ticket information functions.updateTicketInfo(workingTicketId, comboBoxPriority.SelectedIndex, comboBoxStatus.SelectedIndex, textBoxComment.Text); // gives feedback labelFeedback.Text = "Updated"; // updates the active ticket list populateActiveTicketList(); // marks working ticket row in list dataGridActiveTicketList.Rows[workingGridIndex].Selected = true; // checks for change of ticket status if (comboBoxStatus.SelectedIndex != workingTicketStatus) { // checks if contact person exists if (labelContactPersonValue.Text.ToString() != "") { // sends email to contact person functions.sendStatusEmail(labelContactPersonValue.Text, comboBoxStatus.SelectedIndex, workingTicketId, textBoxDescription.Text); } // updates working ticket status workingTicketStatus = comboBoxStatus.SelectedIndex; } } } </code></pre> <p>and the send email function:</p> <pre><code>// sends a status email to contact person // returns noting public void sendStatusEmail(string email, int newStatus, int ticketId, string ticketText) { // defines variables string emailSubject; string emailBody; // some exkluded mailcontent handling // sends mail MailMessage mail = new MailMessage("myFromEmail@hidden.com",email,emailSubject,emailBody); SmtpClient client = new SmtpClient(ConfigurationManager.AppSettings["MailSMTP"]); mail.IsBodyHtml = true; client.Send(mail); // dispose mail.Dispose(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload