public void SetUp() { _smtpTestAccount = new SmtpAccount(); _smtpTestAccount.AccountId = "TestAccountId"; _smtpTestAccount.Address = "*****@*****.**"; _smtpTestAccount.UserName = "******"; _smtpTestAccount.Server = "randomHost"; _smtpTestAccount.Port = 25; _smtpTestAccount.Ssl = false; _smtpTestAccount.Password = "******"; _profile = new ConversionProfile(); _profile.EmailSmtpSettings.Enabled = true; _profile.EmailSmtpSettings.AccountId = _smtpTestAccount.AccountId; _profile.EmailSmtpSettings.Recipients = "*****@*****.**"; _profile.EmailSmtpSettings.Subject = ""; _profile.EmailSmtpSettings.Content = ""; _profile.EmailSmtpSettings.AddSignature = false; _accounts = new Accounts(); _accounts.SmtpAccounts.Add(_smtpTestAccount); _mailSignatureHelper = Substitute.For <IMailSignatureHelper>(); _mailSignatureHelper.ComposeMailSignature().Returns("Signature!"); _smtpAction = new SmtpMailAction(_mailSignatureHelper); }
/// <summary> /// Apply all Actions according to the configuration /// </summary> protected virtual void SetUpActions() { // it does not work yet... /*if (Profile.Stamping.Enable) * { * StampPdfAction stamp = new StampPdfAction(Profile.Stamping.StampText, Profile.Stamping.FontName); * JobActions.Add(stamp); * }*/ if (Profile.Scripting.Enabled) { AddAction(new ScriptAction()); Logger.Trace("Script-Action added"); } if (Profile.OpenViewer) { var defaultViewerAction = new DefaultViewerAction(true); defaultViewerAction.RecommendPdfArchitect += OnRecommendPdfArchitect; AddAction(defaultViewerAction); Logger.Trace("Viewer-Action added"); } if (Profile.Printing.Enabled) { AddAction(new PrintingAction(_ghostScript)); Logger.Trace("Print-Action added"); } if (Profile.EmailSmtp.Enabled) { var smtpMailAction = new SmtpMailAction(JobTranslations.EmailSignature); smtpMailAction.QueryRetypeSmtpPassword += OnRetypeSmtpPassword; AddAction(smtpMailAction); Logger.Trace("SMTP-Mail-Action added"); } if (Profile.EmailClient.Enabled) { var eMailClientAction = new EMailClientAction(JobTranslations.EmailSignature); AddAction(eMailClientAction); Logger.Trace("EMail-Client-Action added"); } if (Profile.Ftp.Enabled) { var ftpAction = new FtpAction(); AddAction(ftpAction); Logger.Trace("Ftp-Action added"); } /*if (Profile.AttachMe.Enable) * { * var attachMeAction = new AttachMeAction(); * AddAction(attachMeAction); * Logger.Trace("Attach.Me added"); * }*/ }
public static ActionResult ProfileCheck(ConversionProfile profile) { var actionResult = new ActionResult(); actionResult.AddRange(CheckAutosaveSettings(profile)); actionResult.AddRange(CheckSaveSettings(profile)); actionResult.AddRange(CheckCoverPageSettings(profile)); actionResult.AddRange(CheckAttachmentPageSettings(profile)); actionResult.AddRange(CheckStampingSettings(profile)); actionResult.AddRange(CheckEncryptionSettings(profile)); actionResult.AddRange(CheckBackgroundpageSettings(profile)); actionResult.AddRange(CheckSignatureSettings(profile)); var ftpAction = new FtpAction(); actionResult.AddRange(ftpAction.Check(profile)); var scriptAction = new ScriptAction(); actionResult.AddRange(scriptAction.Check(profile)); var smtpMailAction = new SmtpMailAction(""); actionResult.AddRange(smtpMailAction.Check(profile)); return(actionResult); }
public void TestWith1FileAttachedWithHtml() { InitTest(); _th.GenerateGsJob_WithSetOutput(TestFile.PDFCreatorTestpagePDF); _th.Profile.EmailSmtpSettings.Html = true; _th.Job.Passwords.SmtpPassword = _smtpPassword; _th.Job.TokenReplacer = _tokenReplacer; var smtpAction = new SmtpMailAction(_passwordProvider); smtpAction.ProcessJob(_th.Job); TestSmtpEmail(); }
public void SetUp() { _smtpTestAccount = new SmtpAccount(); _smtpTestAccount.AccountId = "TestAccountId"; _profile = new ConversionProfile(); _profile.EmailSmtpSettings.Enabled = true; _profile.EmailSmtpSettings.AccountId = _smtpTestAccount.AccountId; _accounts = new Accounts(); _accounts.SmtpAccounts.Add(_smtpTestAccount); _smtpAction = new SmtpMailAction(); }
public void TestWith3FilesAttached() { InitTest(); _th.GenerateGsJob_WithSetOutput(TestFile.PDFCreatorTestpagePDF); _th.Job.OutputFiles.Add(_th.Job.OutputFiles[0]); _th.Job.OutputFiles.Add(_th.Job.OutputFiles[0]); _th.Job.Passwords.SmtpPassword = _smtpPassword; _th.Job.TokenReplacer = _tokenReplacer; var smtpAction = new SmtpMailAction(_passwordProvider); smtpAction.ProcessJob(_th.Job); TestSmtpEmail(); }
public void TestWith3FilesAttached() { InitTest(); _th.GenerateGsJob_WithSetOutput(TestFile.PDFCreatorTestpage_GS9_19_PDF); _th.Job.OutputFiles.Add(_th.Job.OutputFiles[0]); _th.Job.OutputFiles.Add(_th.Job.OutputFiles[0]); _th.Job.Passwords.SmtpPassword = _smtpPassword; _th.Job.TokenReplacer = _tokenReplacer; _th.Job.Accounts = _accounts; var smtpAction = new SmtpMailAction(_mailSignatureHelper); smtpAction.ProcessJob(_th.Job); TestSmtpEmail(); }
private void SendTestMailButton_OnClick(object sender, RoutedEventArgs e) { var smtpMailAction = new SmtpMailAction(MailSignatureHelper.ComposeMailSignature(CurrentProfile.EmailSmtp)); var currentProfile = ((ActionsTabViewModel)DataContext).CurrentProfile.Copy(); #region check profile var result = smtpMailAction.Check(currentProfile); if (!result.Success) { var caption = TranslationHelper.Instance.TranslatorInstance.GetTranslation("SmtpEmailActionSettings", "SendTestMail", "Send test mail"); var message = ErrorCodeInterpreter.GetFirstErrorText(result, true); MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.OK, MessageWindowIcon.Error); return; } #endregion #region create job string tempFolder = Path.GetTempPath(); string tmpTestFolder = Path.Combine(tempFolder, "PdfCreatorTest\\SendSmtpTestmail"); Directory.CreateDirectory(tmpTestFolder); string tmpInfFile = Path.Combine(tmpTestFolder, "SmtpTest.inf"); var sb = new StringBuilder(); sb.AppendLine("[1]"); sb.AppendLine("SessionId=1"); sb.AppendLine("WinStation=Console"); sb.AppendLine("UserName=SampleUser1234"); sb.AppendLine("ClientComputer=\\PC1"); sb.AppendLine("PrinterName=PDFCreator"); sb.AppendLine("JobId=1"); sb.AppendLine("DocumentTitle=SmtpTest"); sb.AppendLine(""); File.WriteAllText(tmpInfFile, sb.ToString(), Encoding.GetEncoding("Unicode")); JobTranslations jobTranslations = new JobTranslations(); jobTranslations.EmailSignature = MailSignatureHelper.ComposeMailSignature(true); var tempFolderProvider = new StaticTempFolderProvider(Path.Combine(Path.GetTempPath(), "PDFCreator")); var job = new GhostscriptJob(new JobInfo(tmpInfFile), new ConversionProfile(), tempFolderProvider, jobTranslations); job.Profile = currentProfile; #endregion #region add password if (string.IsNullOrEmpty(Password)) { var pwWindow = new SmtpPasswordWindow(SmtpPasswordMiddleButton.None, currentProfile.EmailSmtp.Address, currentProfile.EmailSmtp.Recipients); if (pwWindow.ShowDialogTopMost() != SmtpPasswordResponse.OK) { Directory.Delete(tmpTestFolder, true); return; } job.Passwords.SmtpPassword = pwWindow.SmtpPassword; } else { job.Passwords.SmtpPassword = Password; } #endregion #region add testfile string testFile = (Path.Combine(tmpTestFolder, "testfile.txt")); File.WriteAllText(testFile, @"PDFCreator", Encoding.GetEncoding("Unicode")); job.OutputFiles.Add(testFile); #endregion LogManager.GetCurrentClassLogger().Info("Send test mail over smtp."); result = smtpMailAction.ProcessJob(job); Directory.Delete(tmpTestFolder, true); if (!result.Success) { var caption = TranslationHelper.Instance.TranslatorInstance.GetTranslation("SmtpEmailActionSettings", "SendTestMail", "Send test mail"); var message = ErrorCodeInterpreter.GetFirstErrorText(result, true); MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.OK, MessageWindowIcon.Error); } else { var caption = TranslationHelper.Instance.TranslatorInstance.GetTranslation("SmtpEmailActionSettings", "SendTestMail", "Send test mail"); var message = TranslationHelper.Instance.TranslatorInstance.GetFormattedTranslation("SmtpEmailActionSettings", "TestMailSent", "Test mail sent to {0}.", job.Profile.EmailSmtp.Recipients); MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.OK, MessageWindowIcon.Info); } }
public void SetUp() { _profile = new ConversionProfile(); _smtpAction = new SmtpMailAction(Substitute.For <ISmtpPasswordProvider>()); }