@@ -339,33 +339,33 @@ private void SendEmail(bool includeScreenshot, SendCompletedEventHandler smtpCli
339339 EnableSsl = EnableSSL ,
340340 DeliveryMethod = SmtpDeliveryMethod . Network ,
341341 UseDefaultCredentials = false ,
342- Credentials = new NetworkCredential ( UserName , Password ) ,
342+ Credentials = new NetworkCredential ( UserName , Password )
343343 } ;
344+
345+ var message = new MailMessage ( new MailAddress ( FromEmail ) , new MailAddress ( ToEmail ) )
346+ { IsBodyHtml = true , Subject = subject , Body = CreateHtmlReport ( userMessage ) } ;
344347
345- using ( var message = new MailMessage ( new MailAddress ( FromEmail ) , new MailAddress ( ToEmail ) ) { IsBodyHtml = true , Subject = subject , Body = CreateHtmlReport ( userMessage ) } )
348+ if ( ScreenShotBinary ? . Length > 0 && includeScreenshot )
346349 {
347- if ( ScreenShotBinary ? . Length > 0 && includeScreenshot )
348- {
349- message . Attachments . Add ( new Attachment ( new MemoryStream ( ScreenShotBinary ) , "Screenshot.png" , "image/png" ) ) ;
350- }
350+ message . Attachments . Add ( new Attachment ( new MemoryStream ( ScreenShotBinary ) , "Screenshot.png" , "image/png" ) ) ;
351+ }
351352
352- if ( smtpClientSendCompleted != null )
353+ if ( smtpClientSendCompleted != null )
354+ {
355+ try
353356 {
354- try
355- {
356- smtpClient . SendCompleted += smtpClientSendCompleted ;
357- smtpClient . SendAsync ( message , "Crash Report" ) ;
358- }
359- catch ( SmtpException smtpException )
360- {
361- smtpClientSendCompleted ( this , new System . ComponentModel . AsyncCompletedEventArgs ( smtpException , true , null ) ) ;
362- }
357+ smtpClient . SendCompleted += smtpClientSendCompleted ;
358+ smtpClient . SendAsync ( message , "Crash Report" ) ;
363359 }
364- else
360+ catch ( SmtpException smtpException )
365361 {
366- smtpClient . Send ( message ) ;
362+ smtpClientSendCompleted ( this , new System . ComponentModel . AsyncCompletedEventArgs ( smtpException , true , null ) ) ;
367363 }
368364 }
365+ else
366+ {
367+ smtpClient . Send ( message ) ;
368+ }
369369 }
370370
371371 #endregion
0 commit comments