private void ThisAddIn_Startup(object sender, EventArgs e) { if (Properties.Settings.Default.OnWorkBeginTime == DateTime.Today) { setTimer(); return; } if (Properties.Settings.Default.AutoHomeWork) { if (DetectEnviroment.isHomeWork()) { var type = TimeCheck.CheckHomeOfficeTime(); var mail = PrepareMail.PrepareHOMail(type); if (mail == null) { return; } if (SendeMailItem(mail, true) && type == 1) { Properties.Settings.Default.OnTimeSend = DateTime.Now.AddHours(8); Properties.Settings.Default.OnTimeSendType = 1; Properties.Settings.Default.OnWorkBeginTime = DateTime.Today; Properties.Settings.Default.Save(); setTimer(); } return; } } if (!Properties.Settings.Default.SilentMode) { new MainForm(this).Show(); } }
public void TestCreateTable() { List <string> header = new List <string> { { "Date" }, { "Amount" }, { "Description" } }; List <List <string> > content = new List <List <string> >() { new List <string>() { { "2015-1-1" }, { "100" }, { "Payment" } }, new List <string>() { { "2015-2-1" }, { "200" }, { "Payment" } } }; var doc = PrepareMail.CreateTable(new TableModel { Header = header, Content = content }); doc.Save("c:\\Temp\\imail\\table" + DateTime.UtcNow.Ticks + ".docx", SaveFormat.Docx); }
public void TestProcessPrintReadyPDF2() { TestSetPrintPreviewEmailAddress(); Dictionary <string, string> varibalesDict = new Dictionary <string, string>(); varibalesDict.Add("Name", "Stas"); varibalesDict.Add("Address1", "Flat 1"); varibalesDict.Add("Address2", "6 Upperkirkgate"); varibalesDict.Add("Address3", ""); varibalesDict.Add("Address4", "Aberdeen"); varibalesDict.Add("Address5", ""); varibalesDict.Add("Postcode", "AB10 1BA"); varibalesDict.Add("Date", "22/12/2014"); byte[] data = PrepareMail.ReplaceParametersAndConvertToPdf(@"c:\ezbob\test-data\imail\test1.docx", varibalesDict); bool success = this.api.ProcessPrintReadyPDF(data, null, false); if (!success) { Log.InfoFormat(this.api.GetErrorMessage()); } Assert.AreEqual(true, success); }
public void TestPrepareMailAndSaveMetadata() { Dictionary <string, string> varibalesDict = new Dictionary <string, string>(); varibalesDict.Add("Name", "Stas"); varibalesDict.Add("Address1", "Flat 1"); varibalesDict.Add("Address2", "6 Upperkirkgate"); varibalesDict.Add("Address3", ""); varibalesDict.Add("Address4", "Aberdeen"); varibalesDict.Add("Address5", ""); varibalesDict.Add("Postcode", "AB10 1BA"); varibalesDict.Add("Date", "22/12/2014"); byte[] data = PrepareMail.ReplaceParametersAndConvertToPdf(@"c:\ezbob\test-data\imail\test1.docx", varibalesDict); var fileMetadata = PrepareMail.SaveFile(data, @"c:\ezbob\test-data\imail\output.pdf", "output.pdf"); int collectionLogID = DB.ExecuteScalar <int>("AddCollectionLog", CommandSpecies.StoredProcedure, new QueryParameter("CustomerID", 47), new QueryParameter("LoanID", 1), new QueryParameter("Type", "CollectionDay7"), new QueryParameter("Method", "Mail"), new QueryParameter("Now", DateTime.UtcNow)); DB.ExecuteNonQuery("AddCollectionSnailMailMetadata", CommandSpecies.StoredProcedure, new QueryParameter("CollectionLogID", collectionLogID), new QueryParameter("Name", fileMetadata.Name), new QueryParameter("ContentType", fileMetadata.ContentType), new QueryParameter("Path", fileMetadata.Path), new QueryParameter("Now", DateTime.UtcNow), new QueryParameter("CollectionSnailMailTemplateID", 29)); }
public void Concatinate2Pdfs() { var fileData = PrepareMail.GetPdfData(@"c:\ezbob\test-data\imail\output.pdf"); var concatData = PrepareMail.ConcatinatePdfFiles(new List <byte[]> { fileData, fileData }); PrepareMail.SaveFile(concatData, @"c:\ezbob\test-data\imail\concatoutput.pdf", "concatoutput"); }
public void sendDelayMail(object sender, EventArgs args) { switch (Properties.Settings.Default.OnTimeSendType) { case 1: SendeMailItem(PrepareMail.PrepareHOMail(2), true); break; case 2: SendeMailItem(PrepareMail.PrepareWorkMail(2), true); break; } timer = null; }
public void TestMailmergeLetterheadPDF() { TestSetPrintPreviewEmailAddress(); StringBuilder sb = new StringBuilder(); sb.AppendLine("Name,Address1,Address2,Address3,Address4,Address5,Postcode,Variable1,Date"); sb.Append("Stas,Flat 1,6 Upperkirkgate,,Aberdeen,,AB10 1BA,Hello," + DateTime.Today.ToString("dd/MM/yyyy")); string csvStr = sb.ToString(); byte[] csvData = System.Text.Encoding.ASCII.GetBytes(csvStr); bool success = this.api.MailmergeLetterheadPDF(PrepareMail.GetPdfData(@"c:\ezbob\test-data\imail\test4.pdf"), csvData, "<u><h3>@Variable1@ @Name@</h3><br /><h4>this is a test mail</h4></u>", false); if (!success) { Log.InfoFormat(this.api.GetErrorMessage()); } Assert.AreEqual(true, success); }
private void button2_Click(object sender, EventArgs e) { MainObj.SendeMailItem(PrepareMail.PrepareHOMail(TimeCheck.CheckOfficeTime()), false); }
public void OnEndHO(Office.IRibbonControl control) { var mail = PrepareMail.PrepareHOMail(2); MainObj.SendeMailItem(mail, false); }
public void OnBeginHO(Office.IRibbonControl control) { var mail = PrepareMail.PrepareHOMail(1); MainObj.SendeMailItem(mail, true); }
public void TestResource() { byte[] data = PrepareMail.ExtractResource("IMailLib.CollectionTemplates.default-notice-to-borrowers.docx"); PrepareMail.SaveFile(data, @"c:\ezbob\test-data\imail\output.docx", "output.docx"); }