diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index fe1b15f6..12bac525 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -231,9 +231,9 @@ function decodeMIME(text: string, encoding?: string, charset: string = 'utf-8'): } } -function extractHtmlBody(htmlContent: string): string { - const bodyMatch = htmlContent.match(/
]*>([\s\S]*?)<\/body>/i); - return bodyMatch ? bodyMatch[1] : htmlContent; +function extractHtmlBody(html: string): string { + const bodyMatch = html.match(/]*>([\s\S]*?)<\/body>/i); + return bodyMatch ? bodyMatch[1] : html; } function decodeMimeContent(content: string): string { @@ -271,91 +271,78 @@ function decodeMimeContent(content: string): string { } function renderEmailContent(email: Email) { + if (!email.body) return null; + try { - // Parse the full email content + // Parse the email content using our MIME decoder const parsed = parseFullEmail(email.body); - // If we have HTML content, display it + // If we have HTML content, render it if (parsed.html) { return ( -