private void Button_Click(object sender, RoutedEventArgs e) { foreach (Order order in DataSource.orders) { if (order.OrderKey == int.Parse(guestrequestkey.Text)) { instance.AddCalendar(order.requete, order.unit); order.status = Status.MailSent; MailMessage mail = new MailMessage(); mail.To.Add("*****@*****.**"); mail.From = new MailAddress(order.unit.Owner.MailAddress); mail.Subject = "mailSubject"; mail.Body = order.ToString(); mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "mahonlev"); smtp.EnableSsl = true; try { smtp.Send(mail); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } }