diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index b20e4bca..81830f74 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -488,30 +488,22 @@ function renderEmailContent(email: Email) { let isHtml = false; if (parsed.html) { - content = parsed.html; + // Use our existing MIME decoding for HTML content + content = decodeMIME(parsed.html, 'quoted-printable', 'utf-8'); isHtml = true; } else if (parsed.text) { - content = parsed.text; + // Use our existing MIME decoding for plain text content + content = decodeMIME(parsed.text, 'quoted-printable', 'utf-8'); isHtml = false; } else { - // Try to extract content directly from body + // Try to extract content directly from body using our existing functions const htmlMatch = email.body.match(/]*>[\s\S]*?<\/html>/i); if (htmlMatch) { - content = htmlMatch[0]; + content = decodeMIME(htmlMatch[0], 'quoted-printable', 'utf-8'); isHtml = true; } else { - content = email.body - .replace(/<[^>]+>/g, '') - .replace(/ /g, ' ') - .replace(/&/g, '&') - .replace(/</g, '<') - .replace(/>/g, '>') - .replace(/"/g, '"') - .replace(/\r\n/g, '\n') - .replace(/=\n/g, '') - .replace(/=3D/g, '=') - .replace(/=09/g, '\t') - .trim(); + // Use our existing text extraction function + content = extractTextFromHtml(email.body); isHtml = false; } }