// send the email in a new thread.. private void SynchonEmilSender_DoWork(object sender, DoWorkEventArgs e) { bool isSent = true; try { _uiMailMainWindow.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate() { sendEmailNotation.Mid = composeMessageTextBox.Mid; sendEmailNotation.lbl_notation_text.Foreground = Brushes.Black; // add once Only. if (!isFound()) { _uiMailMainWindow.stack_send_email_noations.Children.Add(sendEmailNotation); } composeMessageTextBox.Visibility = Visibility.Collapsed; if (composeMessageTextBox.MyTap != null) { composeMessageTextBox.MyTap.IsEnabled = false; } if (composeMessageTextBox.IsForwardMessage) { string str = composeMessageTextBox.mailMessage.Subject; composeMessageTextBox.mailMessage.Subject = "FW:" + str; composeMessageTextBox.btn_send.IsEnabled = false; } if (composeMessageTextBox.IsReplyMessage) { string str = composeMessageTextBox.mailMessage.Subject; composeMessageTextBox.mailMessage.Subject = "RE:" + str; composeMessageTextBox.btn_send.IsEnabled = false; } }); SmtpClient SmtpclientSide = new SmtpClient("smtp.live.com", 587); SmtpclientSide.UseDefaultCredentials = true; SmtpclientSide.DeliveryMethod = SmtpDeliveryMethod.Network; //SmtpclientSide.PickupDirectoryLocation = Directory.GetCurrentDirectory(); SmtpclientSide.Credentials = new System.Net.NetworkCredential(Ulogin.EmailAddress,Ulogin.EmailPassword); SmtpclientSide.EnableSsl =true; // add FW: and RE: composeMessageTextBox.mailMessage.Priority = MailPriority.High; SmtpclientSide.Send(composeMessageTextBox.mailMessage); } catch(SmtpException exp) { isSent = false; MessageBox.Show(exp.StatusCode.ToString()); } finally { if (isSent) { SynchonEmilSender.ReportProgress(100); } else { SynchonEmilSender.ReportProgress(0); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)