Fix email templates for Outlook compatibility and move HTML out of code
- Replace div-based layouts with table-based HTML throughout (max-width/border-radius/display:inline-block ignored by Outlook) - email.match.body: width:100% table with per-cell borders and fixed 130px label column - email.match.job-search-footer: table-based button with bgcolor attribute - email.search-results.empty: div replaced with full-width table - email.search-results.body: remove div wrapper around items - Add email.search-results.scan-summary and email.search-results.item templates - CvSearchEmailSender: remove all hardcoded HTML; render via IEmailTemplateService Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -47,22 +47,22 @@ namespace Email.Data.Migrations
|
||||
// Match result email — body (HTML formatted)
|
||||
Row("email.match.body", "en",
|
||||
@"<h2 style=""color: #2c5282; margin-bottom: 20px; border-bottom: 3px solid #2c5282; padding-bottom: 10px;"">CV Match Report</h2>
|
||||
<table style=""max-width: 500px; margin: 0 auto 30px; border-collapse: collapse; border: 1px solid #ddd;"">
|
||||
<table width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" style=""width: 100%; margin-bottom: 30px; border-collapse: collapse;"">
|
||||
<tr style=""background-color: #2c5282; color: white;"">
|
||||
<td style=""padding: 12px 15px; font-weight: bold; width: 35%;"">CV ID</td>
|
||||
<td style=""padding: 12px 15px;"">{{cvDocumentId}}</td>
|
||||
<td width=""130"" style=""width: 130px; padding: 12px 15px; font-weight: bold; border: 1px solid #2c5282;"">CV ID</td>
|
||||
<td style=""padding: 12px 15px; border: 1px solid #2c5282;"">{{cvDocumentId}}</td>
|
||||
</tr>
|
||||
<tr style=""background-color: #f8f9fa;"">
|
||||
<td style=""padding: 12px 15px; font-weight: bold;"">Job</td>
|
||||
<td style=""padding: 12px 15px;"">{{jobLabel}}</td>
|
||||
<td style=""width: 130px; padding: 12px 15px; font-weight: bold; border: 1px solid #ddd; color: #333;"">Job</td>
|
||||
<td style=""padding: 12px 15px; border: 1px solid #ddd; color: #333;"">{{jobLabel}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style=""padding: 12px 15px; font-weight: bold;"">URL</td>
|
||||
<td style=""padding: 12px 15px;""><a href=""{{jobUrl}}"" style=""color: #2c5282; text-decoration: none;"">{{jobUrl}}</a></td>
|
||||
<td style=""width: 130px; padding: 12px 15px; font-weight: bold; border: 1px solid #ddd; color: #333;"">URL</td>
|
||||
<td style=""padding: 12px 15px; border: 1px solid #ddd;""><a href=""{{jobUrl}}"" style=""color: #2c5282; text-decoration: none;"">{{jobUrl}}</a></td>
|
||||
</tr>
|
||||
<tr style=""background-color: #f8f9fa;"">
|
||||
<td style=""padding: 12px 15px; font-weight: bold;"">Score</td>
|
||||
<td style=""padding: 12px 15px; color: #27ae60; font-weight: bold; font-size: 18px;"">{{score}}%</td>
|
||||
<td style=""width: 130px; padding: 12px 15px; font-weight: bold; border: 1px solid #ddd; color: #333;"">Score</td>
|
||||
<td style=""padding: 12px 15px; border: 1px solid #ddd; color: #27ae60; font-weight: bold; font-size: 18px;"">{{score}}%</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h3 style=""color: #2c5282; margin-top: 25px; margin-bottom: 10px; border-bottom: 2px solid #2c5282; padding-bottom: 5px;"">Summary</h3>
|
||||
@@ -76,22 +76,22 @@ namespace Email.Data.Migrations
|
||||
"Body for the CV match result email (HTML formatted)");
|
||||
Row("email.match.body", "ro",
|
||||
@"<h2 style=""color: #2c5282; margin-bottom: 20px; border-bottom: 3px solid #2c5282; padding-bottom: 10px;"">Report Potrivire CV</h2>
|
||||
<table style=""max-width: 500px; margin: 0 auto 30px; border-collapse: collapse; border: 1px solid #ddd;"">
|
||||
<table width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" style=""width: 100%; margin-bottom: 30px; border-collapse: collapse;"">
|
||||
<tr style=""background-color: #2c5282; color: white;"">
|
||||
<td style=""padding: 12px 15px; font-weight: bold; width: 35%;"">ID Document CV</td>
|
||||
<td style=""padding: 12px 15px;"">{{cvDocumentId}}</td>
|
||||
<td width=""130"" style=""width: 130px; padding: 12px 15px; font-weight: bold; border: 1px solid #2c5282;"">ID Document CV</td>
|
||||
<td style=""padding: 12px 15px; border: 1px solid #2c5282;"">{{cvDocumentId}}</td>
|
||||
</tr>
|
||||
<tr style=""background-color: #f8f9fa;"">
|
||||
<td style=""padding: 12px 15px; font-weight: bold;"">Job</td>
|
||||
<td style=""padding: 12px 15px;"">{{jobLabel}}</td>
|
||||
<td style=""width: 130px; padding: 12px 15px; font-weight: bold; border: 1px solid #ddd; color: #333;"">Job</td>
|
||||
<td style=""padding: 12px 15px; border: 1px solid #ddd; color: #333;"">{{jobLabel}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style=""padding: 12px 15px; font-weight: bold;"">URL</td>
|
||||
<td style=""padding: 12px 15px;""><a href=""{{jobUrl}}"" style=""color: #2c5282; text-decoration: none;"">{{jobUrl}}</a></td>
|
||||
<td style=""width: 130px; padding: 12px 15px; font-weight: bold; border: 1px solid #ddd; color: #333;"">URL</td>
|
||||
<td style=""padding: 12px 15px; border: 1px solid #ddd;""><a href=""{{jobUrl}}"" style=""color: #2c5282; text-decoration: none;"">{{jobUrl}}</a></td>
|
||||
</tr>
|
||||
<tr style=""background-color: #f8f9fa;"">
|
||||
<td style=""padding: 12px 15px; font-weight: bold;"">Scor</td>
|
||||
<td style=""padding: 12px 15px; color: #27ae60; font-weight: bold; font-size: 18px;"">{{score}}%</td>
|
||||
<td style=""width: 130px; padding: 12px 15px; font-weight: bold; border: 1px solid #ddd; color: #333;"">Scor</td>
|
||||
<td style=""padding: 12px 15px; border: 1px solid #ddd; color: #27ae60; font-weight: bold; font-size: 18px;"">{{score}}%</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h3 style=""color: #2c5282; margin-top: 25px; margin-bottom: 10px; border-bottom: 2px solid #2c5282; padding-bottom: 5px;"">Rezumat</h3>
|
||||
@@ -108,13 +108,25 @@ namespace Email.Data.Migrations
|
||||
Row("email.match.job-search-footer", "en",
|
||||
@"<hr style=""border: none; border-top: 1px solid #ddd; margin: 30px 0;"">
|
||||
<p style=""margin-top: 20px; font-size: 14px; color: #333;"">Want to find more jobs matching your CV?</p>
|
||||
<p style=""margin-bottom: 20px;""><a href=""{{jobSearchLink}}"" style=""background-color: #2c5282; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;"">Search Jobs</a></p>
|
||||
<table cellpadding=""0"" cellspacing=""0"" border=""0"" style=""margin-bottom: 20px;"">
|
||||
<tr>
|
||||
<td align=""center"" bgcolor=""#2c5282"" style=""background-color: #2c5282; padding: 10px 20px;"">
|
||||
<a href=""{{jobSearchLink}}"" style=""color: #ffffff; font-weight: bold; text-decoration: none; font-size: 14px; display: block;"">Search Jobs</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p style=""font-size: 12px; color: #666;"">(link valid for {{expiryDays}} days)</p>",
|
||||
"Job search CTA appended to match result email (HTML formatted)");
|
||||
Row("email.match.job-search-footer", "ro",
|
||||
@"<hr style=""border: none; border-top: 1px solid #ddd; margin: 30px 0;"">
|
||||
<p style=""margin-top: 20px; font-size: 14px; color: #333;"">Vrei să găsești mai multe joburi potrivite CV-ului tău?</p>
|
||||
<p style=""margin-bottom: 20px;""><a href=""{{jobSearchLink}}"" style=""background-color: #2c5282; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;"">Caută Joburi</a></p>
|
||||
<table cellpadding=""0"" cellspacing=""0"" border=""0"" style=""margin-bottom: 20px;"">
|
||||
<tr>
|
||||
<td align=""center"" bgcolor=""#2c5282"" style=""background-color: #2c5282; padding: 10px 20px;"">
|
||||
<a href=""{{jobSearchLink}}"" style=""color: #ffffff; font-weight: bold; text-decoration: none; font-size: 14px; display: block;"">Caută Joburi</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p style=""font-size: 12px; color: #666;"">(link valabil {{expiryDays}} zile)</p>",
|
||||
"CTA cautare joburi adaugat la emailul de potrivire CV (format HTML)");
|
||||
|
||||
@@ -126,34 +138,84 @@ namespace Email.Data.Migrations
|
||||
Row("email.search-results.body", "en",
|
||||
@"<h2 style=""color: #2c5282; margin-bottom: 20px; border-bottom: 3px solid #2c5282; padding-bottom: 10px;"">Job Search Results</h2>
|
||||
<p style=""margin-bottom: 20px; color: #333;"">MyAi.ro found <strong>{{count}}</strong> jobs matching your CV:</p>
|
||||
<div style=""margin-top: 20px; color: #333;"">
|
||||
{{items}}
|
||||
</div>",
|
||||
{{items}}",
|
||||
"Body preamble for job search results email (HTML formatted)");
|
||||
Row("email.search-results.body", "ro",
|
||||
@"<h2 style=""color: #2c5282; margin-bottom: 20px; border-bottom: 3px solid #2c5282; padding-bottom: 10px;"">Rezultate Căutare Joburi</h2>
|
||||
<p style=""margin-bottom: 20px; color: #333;"">MyAi.ro a găsit <strong>{{count}}</strong> joburi potrivite CV-ului tău:</p>
|
||||
<div style=""margin-top: 20px; color: #333;"">
|
||||
{{items}}
|
||||
</div>",
|
||||
{{items}}",
|
||||
"Corpul emailului de rezultate cautare joburi (format HTML)");
|
||||
|
||||
// Job search results email — scan summary block (keywords + providers used)
|
||||
Row("email.search-results.scan-summary", "en",
|
||||
@"<table width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" style=""width: 100%; margin-bottom: 18px; border: 1px solid #dee2e6; border-collapse: collapse;"">
|
||||
<tr>
|
||||
<td bgcolor=""#f8f9fa"" style=""background-color: #f8f9fa; padding: 14px 16px; font-size: 13px; color: #495057;"">
|
||||
<div style=""margin-bottom: 8px;""><strong>Keywords used:</strong> {{keywordsHtml}}</div>
|
||||
<div><strong>Providers scanned:</strong> {{providers}}</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>",
|
||||
"Scan summary block prepended to job search results email (HTML formatted)");
|
||||
Row("email.search-results.scan-summary", "ro",
|
||||
@"<table width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" style=""width: 100%; margin-bottom: 18px; border: 1px solid #dee2e6; border-collapse: collapse;"">
|
||||
<tr>
|
||||
<td bgcolor=""#f8f9fa"" style=""background-color: #f8f9fa; padding: 14px 16px; font-size: 13px; color: #495057;"">
|
||||
<div style=""margin-bottom: 8px;""><strong>Cuvinte cheie folosite:</strong> {{keywordsHtml}}</div>
|
||||
<div><strong>Furnizori scanați:</strong> {{providers}}</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>",
|
||||
"Bloc rezumat scanare adaugat la emailul de rezultate cautare joburi (format HTML)");
|
||||
|
||||
// Job search results email — single job result item card
|
||||
Row("email.search-results.item", "en",
|
||||
@"<table width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" style=""width: 100%; margin-bottom: 12px; border: 1px solid #dee2e6; border-collapse: collapse;"">
|
||||
<tr>
|
||||
<td style=""padding: 12px 16px; background-color: #ffffff;"">
|
||||
<strong style=""color: #212529;"">{{index}}. {{jobTitle}}</strong>
|
||||
<span style=""background: #28a745; color: #fff; padding: 2px 8px; font-size: 12px; margin-left: 8px;"">{{score}}% match</span>
|
||||
<span style=""color: #6c757d; font-size: 12px; margin-left: 4px;"">[{{providerName}}]</span><br>
|
||||
<a href=""{{jobUrl}}"" style=""color: #2c5282; font-size: 13px;"">{{jobUrl}}</a>
|
||||
{{summary}}
|
||||
</td>
|
||||
</tr>
|
||||
</table>",
|
||||
"Single job result card in job search results email (HTML formatted)");
|
||||
Row("email.search-results.item", "ro",
|
||||
@"<table width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" style=""width: 100%; margin-bottom: 12px; border: 1px solid #dee2e6; border-collapse: collapse;"">
|
||||
<tr>
|
||||
<td style=""padding: 12px 16px; background-color: #ffffff;"">
|
||||
<strong style=""color: #212529;"">{{index}}. {{jobTitle}}</strong>
|
||||
<span style=""background: #28a745; color: #fff; padding: 2px 8px; font-size: 12px; margin-left: 8px;"">{{score}}% potrivire</span>
|
||||
<span style=""color: #6c757d; font-size: 12px; margin-left: 4px;"">[{{providerName}}]</span><br>
|
||||
<a href=""{{jobUrl}}"" style=""color: #2c5282; font-size: 13px;"">{{jobUrl}}</a>
|
||||
{{summary}}
|
||||
</td>
|
||||
</tr>
|
||||
</table>",
|
||||
"Card job individual in emailul de rezultate cautare joburi (format HTML)");
|
||||
|
||||
// Job search results email — no results found - HTML formatted
|
||||
Row("email.search-results.empty", "en",
|
||||
@"<div style=""background-color: #fff3cd; border: 1px solid #ffc107; border-radius: 4px; padding: 15px; margin: 20px 0;"">
|
||||
<p style=""margin: 0; color: #856404;"">
|
||||
<strong>No jobs found</strong><br>
|
||||
MyAi.ro found no jobs matching your CV at this moment. Please try again later or update your CV to improve your match results.
|
||||
</p>
|
||||
</div>",
|
||||
@"<table width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" style=""width: 100%; margin: 20px 0;"">
|
||||
<tr>
|
||||
<td bgcolor=""#fff3cd"" style=""background-color: #fff3cd; border: 1px solid #ffc107; padding: 15px;"">
|
||||
<p style=""margin: 0; color: #856404;""><strong>No jobs found</strong><br>
|
||||
MyAi.ro found no jobs matching your CV at this moment. Please try again later or update your CV to improve your match results.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>",
|
||||
"No results message for job search results email (HTML formatted)");
|
||||
Row("email.search-results.empty", "ro",
|
||||
@"<div style=""background-color: #fff3cd; border: 1px solid #ffc107; border-radius: 4px; padding: 15px; margin: 20px 0;"">
|
||||
<p style=""margin: 0; color: #856404;"">
|
||||
<strong>Niciun job găsit</strong><br>
|
||||
MyAi.ro nu a găsit joburi potrivite CV-ului tău în acest moment. Te rugăm să încerci din nou mai târziu sau să-ți actualizezi CV-ul pentru a obține rezultate mai bune.
|
||||
</p>
|
||||
</div>",
|
||||
@"<table width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" style=""width: 100%; margin: 20px 0;"">
|
||||
<tr>
|
||||
<td bgcolor=""#fff3cd"" style=""background-color: #fff3cd; border: 1px solid #ffc107; padding: 15px;"">
|
||||
<p style=""margin: 0; color: #856404;""><strong>Niciun job găsit</strong><br>
|
||||
MyAi.ro nu a găsit joburi potrivite CV-ului tău în acest moment. Te rugăm să încerci din nou mai târziu sau să-ți actualizezi CV-ul pentru a obține rezultate mai bune.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>",
|
||||
"Mesaj fara rezultate pentru emailul de cautare joburi (format HTML)");
|
||||
|
||||
// HTML job-search start page messages
|
||||
|
||||
@@ -89,7 +89,7 @@ public sealed class CvSearchEmailSender
|
||||
/// </summary>
|
||||
private string BuildBody(IReadOnlyList<JobSearchResultEntity> results, IReadOnlyList<string> keywords, IReadOnlyList<string> providerNames, string language)
|
||||
{
|
||||
var scanSummary = BuildScanSummary(keywords, providerNames);
|
||||
var scanSummary = BuildScanSummary(keywords, providerNames, language);
|
||||
|
||||
if (results.Count == 0)
|
||||
return scanSummary + _emailTemplates.Get("email.search-results.empty", language);
|
||||
@@ -98,18 +98,18 @@ public sealed class CvSearchEmailSender
|
||||
for (int i = 0; i < results.Count; i++)
|
||||
{
|
||||
var r = results[i];
|
||||
var matchResp = TryParseResult(r.ResultJson);
|
||||
var summary = matchResp?.Summary;
|
||||
var summary = TryParseResult(r.ResultJson)?.Summary;
|
||||
var summaryHtml = string.IsNullOrWhiteSpace(summary)
|
||||
? ""
|
||||
: $"<p style=\"margin:8px 0 0;color:#495057;font-size:14px;line-height:1.5;\">{summary}</p>";
|
||||
|
||||
items.Append($"""
|
||||
<div style="border:1px solid #dee2e6;border-radius:6px;padding:16px;margin-bottom:12px">
|
||||
<strong style="color:#212529">{i + 1}. {r.JobTitle}</strong>
|
||||
<span style="background:#28a745;color:#fff;padding:2px 8px;border-radius:12px;font-size:12px;margin-left:8px">{r.Score}% match</span>
|
||||
<span style="color:#6c757d;font-size:12px;margin-left:4px">[{r.ProviderName}]</span><br>
|
||||
<a href="{r.JobUrl}" style="color:#2c5282;font-size:13px">{r.JobUrl}</a>
|
||||
{(string.IsNullOrWhiteSpace(summary) ? "" : $"<p style=\"margin:8px 0 0;color:#495057;font-size:14px;line-height:1.5\">{summary}</p>")}
|
||||
</div>
|
||||
""");
|
||||
items.Append(_emailTemplates.Render("email.search-results.item", language,
|
||||
("index", (i + 1).ToString()),
|
||||
("jobTitle", r.JobTitle),
|
||||
("score", r.Score.ToString()),
|
||||
("providerName", r.ProviderName),
|
||||
("jobUrl", r.JobUrl),
|
||||
("summary", summaryHtml)));
|
||||
}
|
||||
|
||||
return _emailTemplates.Render("email.search-results.body", language,
|
||||
@@ -118,25 +118,23 @@ public sealed class CvSearchEmailSender
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the scan summary block showing the CV keywords and providers used for the search.
|
||||
/// Renders the scan summary block via template, passing keyword tags and provider list as data.
|
||||
/// Keyword tags are built here because they are variable-count inline elements, not structural HTML.
|
||||
/// </summary>
|
||||
private static string BuildScanSummary(IReadOnlyList<string> keywords, IReadOnlyList<string> providerNames)
|
||||
private string BuildScanSummary(IReadOnlyList<string> keywords, IReadOnlyList<string> providerNames, string language)
|
||||
{
|
||||
var keywordsHtml = keywords.Count > 0
|
||||
? string.Join(" ", keywords.Select(k =>
|
||||
$"<span style=\"display:inline-block;background:#e9ecef;border-radius:4px;padding:2px 8px;margin:2px 2px 2px 0;font-size:12px\">{k}</span>"))
|
||||
: "<span style=\"color:#6c757d;font-size:12px;font-style:italic\">none detected</span>";
|
||||
$"<span style=\"display:inline-block;background:#e9ecef;padding:2px 8px;margin:2px 2px 2px 0;font-size:12px;\">{k}</span>"))
|
||||
: "<span style=\"color:#6c757d;font-size:12px;font-style:italic;\">none detected</span>";
|
||||
|
||||
var providersText = providerNames.Count > 0
|
||||
var providers = providerNames.Count > 0
|
||||
? string.Join(", ", providerNames)
|
||||
: "none";
|
||||
|
||||
return $"""
|
||||
<div style="background:#f8f9fa;border:1px solid #dee2e6;border-radius:6px;padding:14px 16px;margin-bottom:18px;font-size:13px;color:#495057">
|
||||
<div style="margin-bottom:8px"><strong>Keywords used:</strong> {keywordsHtml}</div>
|
||||
<div><strong>Providers scanned:</strong> {providersText}</div>
|
||||
</div>
|
||||
""";
|
||||
return _emailTemplates.Render("email.search-results.scan-summary", language,
|
||||
("keywordsHtml", keywordsHtml),
|
||||
("providers", providers));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user