public DesignTimeMailBaseControlViewModel() : base(new DesignTimeTranslationUpdater(), new DesignTimeCurrentSettingsProvider(), null, null) { MailActionSettings = new EmailClientSettings(); MailActionSettings.AdditionalAttachments = new List <string> { "test1", "test2", "test3" }; }
public bool SendTestEmail(EmailClientSettings clientSettings) { var emailClient = _emailClientFactory.CreateEmailClient(); if (emailClient == null) { return(false); } var eMail = new Email(); var tokenReplacer = _tokenHelper.TokenReplacerWithPlaceHolders; clientSettings.Recipients = tokenReplacer.ReplaceTokens(clientSettings.Recipients); foreach (var recipient in clientSettings.Recipients.Replace(',', ';').Split(';')) { if (!string.IsNullOrWhiteSpace(recipient)) { eMail.To.Add(recipient.Trim()); } } eMail.Subject = tokenReplacer.ReplaceTokens(clientSettings.Subject); eMail.Html = clientSettings.Html; eMail.Body = tokenReplacer.ReplaceTokens(clientSettings.Content); if (clientSettings.AddSignature) { var signature = _mailSignatureHelper.ComposeMailSignature(); if (clientSettings.Html) { signature = signature.Replace(Environment.NewLine, "<br/>"); } eMail.Body += signature; } try { var tempFolder = _path.GetTempPath(); var tmpTestFolder = _pathSafe.Combine(tempFolder, "PDFCreator-Test\\SendSmtpTestmail"); _directory.CreateDirectory(tmpTestFolder); var tmpFile = _pathSafe.Combine(tmpTestFolder, "PDFCreator Mail Client Test.pdf"); _file.WriteAllText(tmpFile, ""); eMail.Attachments.Add(new Attachment(tmpFile)); emailClient.ShowEmailClient(eMail); } catch (Exception ex) { _logger.Warn(ex, "Exception while creating mail"); return(false); } return(true); }
public void Setup() { _pathWrap = Substitute.For <IPath>(); _directoryWrap = Substitute.For <IDirectory>(); _fileWrap = Substitute.For <IFile>(); _emailClient = Substitute.For <IEmailClient>(); _emailClientFactory = Substitute.For <IEmailClientFactory>(); _emailClientFactory.CreateEmailClient().Returns(_emailClient); _mailSignatureHelper = Substitute.For <IMailSignatureHelper>(); _clientTestEmail = new ClientTestEmail(_emailClientFactory, _mailSignatureHelper, _pathWrap, _directoryWrap, _fileWrap); _emailClientSettings = new EmailClientSettings(); }
public string ComposeMailSignature(EmailClientSettings mailSettings) { return(ComposeMailSignature(mailSettings.AddSignature)); }
public bool SendTestEmail(EmailClientSettings clientSettings) { return(true); }