private void InsertSMSClick() { if (string.IsNullOrWhiteSpace(TBoxMID) || string.IsNullOrWhiteSpace(TBoxSender) || string.IsNullOrWhiteSpace(TBoxBody)) { MessageBox.Show("Please fill out all boxes please"); return; } EmailAdd AddEmail = new EmailAdd(); { AddEmail.MessageID = "E" + TBoxMID; AddEmail.Sender = TBoxSender; AddEmail.Subject = TBoxSubject; AddEmail.Body = TBoxBody; } ListEmail.Add(AddEmail); SaveToFile save = new SaveToFile(); if (!save.EmailToCSV(ListEmail, MessageType)) { MessageBox.Show("Error while saving\n" + save.ErrorCode); } else { save = null; } MessageBox.Show("Order saved"); }
// Post: Admin/Tag/Add/id public virtual ActionResult Add(EmailAdd model) { if (!ModelState.IsValid) { return(View(model)); } string[] emails; bool result; if (!string.IsNullOrEmpty(Request["Emails[]"])) { emails = Request["Emails[]"].Split(','); foreach (string email in emails) { result = Utilities.Email.MailSender.SendMail(model.Title, model.Body, email); if (result) { _emailService.Add(new Email { Title = model.Title, Body = model.Body, SendTime = DateTime.Now, EmailAddress = email }); } } } _uow.SaveAllChanges(); return(RedirectToAction("Index")); }
public ActionResult SendEmail(EmailAdd objModelMail) { if (ModelState.IsValid) { string from = "*****@*****.**"; //Email like- [email protected] using (MailMessage mail = new MailMessage(from, objModelMail.To)) { mail.Subject = objModelMail.Subject; mail.Body = objModelMail.Body; mail.IsBodyHtml = false; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential networkCredential = new NetworkCredential(from, "a9843368280k"); smtp.UseDefaultCredentials = true; smtp.Credentials = networkCredential; smtp.Port = 587; smtp.Send(mail); //ViewBag.Message = "EmailSent"; return(Ok(smtp)); } } else { return(Ok()); } }
// GET: Admin/Tag/Add public virtual ActionResult Add() { EmailAdd emailAdd = new EmailAdd(); emailAdd.EmailTemplateList = _emailTemplateService.DropDownList(); emailAdd.UserList = _userService.DropDownList(); return(View(emailAdd)); }
private void AddRequest_Click(object sender, RoutedEventArgs e) { try { myIBL.AddGuestRequest(NewGuestRequest); Window mainGuest = new GuestMainWindow(guest); mainGuest.Show(); this.Close(); } catch (DateOrderException) { MessageBox.Show("The entry date must be before the release date.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); EndingDate.SelectedDate = NewGuestRequest.EntryDate.AddDays(1); } catch (DateComparedToTodayException) { MessageBox.Show("The vacation cannot be in the past.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); StartingDate.SelectedDate = DateTime.Today; EndingDate.SelectedDate = DateTime.Today.AddDays(1); } catch (NotValidEmailAddressException) { MessageBox.Show("The email address must be valid.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); EmailAdd.Focus(); } catch (ChildrenAmountException) { MessageBox.Show("There cannot be a negative amount of people, this is earth!!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); numChildren.Text = "0"; numChildren.Focus(); } catch (AdultAmountException) { MessageBox.Show("if there are no adults, who is requesting the vacation?!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); numAdults.Text = "1"; numAdults.Focus(); } }
private void InsertSMSClick() { var email = new EmailAddressAttribute(); var website = new UrlAttribute(); if (email.IsValid(TBoxSender)) { string[] Body = TBoxBody.Split(' '); foreach (string word in Body) { WebCheck = word; if (website.IsValid(word) || word.Contains("www")) { ListAdd Quarantine = new ListAdd(); { Quarantine.ListType = word; Quarantine.Count = "1"; } ListType = "Q"; ListQuarantine.Add(Quarantine); SaveToList Q = new SaveToList(); if (!Q.WriteToCSV(ListQuarantine, ListType)) { MessageBox.Show("Error while saving\n" + Q.ErrorCode); } else { Q = null; } WebCheck = WebCheck.Replace(WebCheck, "<URL Quarantined>"); MessageBox.Show(WebCheck); for (int x = 0; x < Body.Length; x++) { if (Body[x] == word) { Body[x] = Body[x].Replace(word, WebCheck); } } } } TBoxBody = string.Join(" ", Body); MessageBox.Show(TBoxBody); EmailAdd AddEmail = new EmailAdd(); { AddEmail.MessageID = "E" + TBoxMID; AddEmail.Sender = TBoxSender; try { AddEmail.Subject = "SIR " + DPickerContent.ToString(); check = true; } catch (Exception ex) { MessageBox.Show("Please Select a date"); check = false; } AddEmail.Body = CentreCode + "" + Incident + "" + TBoxBody; } if (check == true) { ListEmail.Add(AddEmail); SaveToFile save = new SaveToFile(); if (!save.EmailToCSV(ListEmail, MessageType)) { MessageBox.Show("Error while saving\n" + save.ErrorCode); } else { save = null; } ListAdd SIRList = new ListAdd(); { SIRList.ListType = AddEmail.Subject; SIRList.Count = "66-666-99"; } ListType = "S"; ListSIR.Add(SIRList); SaveToList SIR = new SaveToList(); if (!SIR.WriteToCSV(ListSIR, ListType)) { MessageBox.Show("Error while saving\n" + SIR.ErrorCode); } else { SIR = null; } MessageBox.Show("Order saved"); } } else { MessageBox.Show("Wrong"); } }
//Производим очищение первоначальных данных при нажатии 2 раза ЛКМ private void EmailAdd_MouseDoubleClick(object sender, MouseButtonEventArgs e) { EmailAdd.Clear(); }