Note that there are some explanatory texts on larger screens.

plurals
  1. POE-mail with no content when using the System.Threading.ThreadPool
    primarykey
    data
    text
    <p>I'm experiencing a strange behavior trying to send email using <code>Threading.ThreadPool</code>.</p> <p>This has worked for over a year now but recently it has stated to intermittently send emails with no content. The addressees and subject are all fine, however, the rest of the email is blank. Nothing has changed code wise (apart from Windows updates to the server it runs on).</p> <p>Here's the code I'm using - does anyone have a suggestion of how I might narrow down where the problem is occurring? Upon re-sending the email to someone who has claimed of receiving a blank email they get it fine - it uses the exact same code as the first one that was sent.</p> <p><strong>Sub to generate email:</strong></p> <pre><code> Public Sub EmailConfirmation(email As String, firstname As String, details As String) Try Dim embody As String = GlobalHelper.emailBody 'static class which loads the email text at application load for use later. 'This is a point of concern because it's obviously where the embody text is 'is loaded, but the issue is intermittent and if there was a failure here surely 'it would be caught by the 'try...catch' and a log of the error created (which has 'never happened). I also ran an experiment for a while where if this string was 'empty then create a log entry. After receiving a complaint of a blank email 'no error log was found. embody = Replace(embody, "[FirstName]", firstname) embody = Replace(embody, "[DATA]", details) 'create the mail message Dim mail As New MailMessage() 'set the addresses mail.From = New MailAddress("myemail@mydomain.com", "My Display Name") mail.To.Add(email) mail.IsBodyHtml = True 'set the content mail.Subject = "Email Subject!" mail.Body = embody AddEmailToThreadPool(mail) Catch ex As Exception 'if there is an error it is logged here. End Try End Sub </code></pre> <p><strong>Sub that adds to ThreadPool:</strong></p> <pre><code>Private Sub AddEmailToThreadPool(email As MailMessage) System.Threading.ThreadPool.QueueUserWorkItem(New System.Threading.WaitCallback(AddressOf sendEmail), email) End Sub </code></pre> <p><strong>Sub that sends email:</strong></p> <pre><code>Private Sub sendEmail(stateinfo As Object) Dim email As MailMessage = CType(stateinfo, MailMessage) Try 'send the message Dim smtp As New SmtpClient("mail.mydomain.com") smtp.Send(email) Catch ex As Exception 'error is logged here. End Try End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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