public void SendMail() { SimpleMail.SMTPClient smtp = new SimpleMail.SMTPClient(); MailMessage mm = new MailMessage("*****@*****.**", "*****@*****.**"); mm.Body = txtMore.Text; mm.Subject = ErrorBox.Text; mm.BodyEncoding = UTF8Encoding.UTF8; mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; smtp.SendMail(mm); }
//-- //-- this is the code that executes in the spawned thread //-- private static void ThreadHandler() { SimpleMail.SMTPClient objMail = new SimpleMail.SMTPClient(); //SimpleMail.SMTPMailMessage objMailMessage = new SimpleMail.SMTPMailMessage(); //var _with3 = objMailMessage; //_with3.To = "*****@*****.**"; //_with3.Subject = "Unhandled Exception notification - " + _strExceptionType; //_with3.Body = _strException; //if (_blnLogToScreenshot & _blnEmailIncludeScreenshot) //{ // _with3.AttachmentPath = _strScreenshotFullPath; //} //try //{ // objMail.SendMail(objMailMessage); // _blnLogToEmailOK = true; //} //catch (Exception e) //{ // _blnLogToEmailOK = false; // //-- don't do anything; sometimes SMTP isn't available, which generates an exception // //-- and an exception in the unhandled exception manager.. is bad news. // //--MsgBox("exception email failed to send:" + Environment.Newline + Environment.Newline + e.Message) //} MailMessage mm = new MailMessage("*****@*****.**", "*****@*****.**"); mm.Body = _strException; mm.Subject = "Unhandled Exception notification - " + _strExceptionType; if (_blnLogToScreenshot & _blnEmailIncludeScreenshot) { mm.Attachments.Add(new Attachment(_strScreenshotFullPath)); } mm.BodyEncoding = UTF8Encoding.UTF8; mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; objMail.SendMail(mm); }