public static void SendEmailWithAttachement(ClientEntity clientEntity, EmailEntity emailEntity, IInvoiceDetails invoiceDetails, string pdfFileName, DateTime now) { var subject = "Invoice #" + InvoiceNameGenerator.GetName(invoiceDetails.Number, now); var sender = new Sender(new DefaultSmtpWrapper().Data); var body = EmailBodyCreator.Create(emailEntity, clientEntity.PointOfContactName); sender.Send(clientEntity.PointOfContactEmail, subject, body, new List<string> { pdfFileName }); }
public static void RunAutomatedWeeklyInvoice(Repository repository) { var client = repository.ClientsWrapper.Data.FirstOrDefault(x => x.Id == repository.InvoiceWrapper.Data.ClientId); var sender = new Sender(new DefaultSmtpWrapper().Data); if (client == null) { sender.Send("*****@*****.**", "Automated invoice failure", "No client detected with id: " + repository.InvoiceWrapper.Data.ClientId, new List<string>()); } var now = GetDate(); var pdfFilename = new Generator().CreateWeeklyInvoice(repository.InvoiceWrapper.Data, repository.InvoiceWrapper.Data.WeeklyInvoiceDetails, client, repository.CompanyInformationWrapper.Data, now, repository.StorageWrapper.Data.InvoiceDirectory); InvoiceEmailer.SendEmailWithAttachement(client, repository.EmailWrapper.Data, repository.InvoiceWrapper.Data.WeeklyInvoiceDetails, pdfFilename, now); sender.Send("*****@*****.**", "Automated invoice success", "Sent invoice with id: " + repository.InvoiceWrapper.Data.WeeklyInvoiceDetails.Number, new List<string>()); repository.InvoiceWrapper.Data.WeeklyInvoiceDetails.Number++; repository.InvoiceWrapper.Save(); }
public void SendEmail() { var sender = new Sender(new DefaultSmtpWrapper().Data); Assert.DoesNotThrow(() => sender.Send("*****@*****.**", "Subject Line Test", "Body Test", null)); }
public static void MailAll(Repository repo) { var emailAddresses = File.ReadAllLines(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.ConvergedEmailAddressesFilename).ToList(); var sender = new Sender(repo.SmtpWrapper.Data); if (!File.Exists(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.EmailAddressesSentSucesfully)) { File.Create(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.EmailAddressesSentSucesfully); } var alreadySent = File.ReadAllLines(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.EmailAddressesSentSucesfully).ToList(); const string mik = "*****@*****.**"; if (!alreadySent.Contains(mik)) { using (var w = File.AppendText(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.EmailAddressesSentSucesfully)) { w.WriteLine(); } alreadySent.Add(mik); } var percentIndicator = 0; var processed = 0; foreach (var emailAddress in emailAddresses) { var percent = (int)Math.Round((100.0 / emailAddresses.Count) * processed); if (percent != percentIndicator) { percentIndicator = percent; Console.WriteLine("{0}% complete", percentIndicator); } if (!alreadySent.Contains(emailAddress) && !string.IsNullOrEmpty(emailAddress)) { if (IsValidEmail(emailAddress)) { sender.Send(emailAddress, Subject, GetRecruitmentBody(), GetCVs()); Console.WriteLine("Sent to {0}", emailAddress); alreadySent.Add(emailAddress); using (var w = File.AppendText(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.EmailAddressesSentSucesfully)) { w.WriteLine(emailAddress); } }else { Console.WriteLine("invalid: {0}", emailAddress); } } else { Console.WriteLine("skipping {0}", emailAddress); } processed++; } if (UIRetriever.GetBool(string.Format("View {0}?", repo.StorageWrapper.Data.MineableDataResultsDirectory))) { DirectoryVisualiser.ShowFile(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.EmailAddressesSentSucesfully); } }
public static void MailTest(Repository repo) { var clientEntity = ClientSelector.Get(repo.ClientsWrapper.Data); var sender = new Sender(repo.SmtpWrapper.Data); sender.Send(clientEntity.PointOfContactEmail, Subject, GetRecruitmentBody(), GetCVs()); sender.Send("*****@*****.**", Subject, GetRecruitmentBody(), GetCVs()); }