Пример #1
0
        private void Send(AppVersionInfo versionInfo, string recipients)
        {
            string body    = EmbeddedResourceProvider.GetResourceString("NewVersionAvailableEmail.html", "EmbeddedResources.Templates");
            string subject = GetSubjectLine(body) ?? "New version available";

            Dictionary <string, string> tokens = new Dictionary <string, string>()
            {
                { "{url}", versionInfo.UpdateUrl },
                { "{version}", versionInfo.AvailableVersion.ToString() },
                { "{releaseNotes}", versionInfo.ReleaseNotes },
            };

            body    = TokenReplacer.ReplaceAsHtml(tokens, body);
            subject = TokenReplacer.ReplaceAsPlainText(tokens, subject);

            this.smtpProvider.SendEmail(recipients, subject, body);
        }
Пример #2
0
        private void Send(X509Certificate2 cert, string recipients, bool hasExpired, int daysRemaining)
        {
            string body    = EmbeddedResourceProvider.GetResourceString("CertificateExpiringEmail.html", "EmbeddedResources.Templates");
            string subject = hasExpired ? "TLS Certificate has expired" : "TLS Certificate is expiring soon";

            Dictionary <string, string> tokens = new Dictionary <string, string>()
            {
                { "{thumbprint}", cert.Thumbprint },
                { "{notBefore}", cert.NotBefore.ToString() },
                { "{notAfter}", cert.NotAfter.ToString() },
                { "{subject}", cert.Subject },
                { "{daysToExpiry}", hasExpired ? "0" : daysRemaining.ToString() },
                { "{serialNumber}", cert.SerialNumber },
                { "{expiryNotice}", hasExpired ? "The Access Manager TLS certificate has expired" : $"The Access Manager TLS certificate expires in {daysRemaining} day{(daysRemaining == 1 ? "" :"s")}" },
            };

            body    = TokenReplacer.ReplaceAsHtml(tokens, body);
            subject = TokenReplacer.ReplaceAsPlainText(tokens, subject);

            this.smtpProvider.SendEmail(recipients, subject, body);
        }