diff --git a/app/api/courrier/[id]/route.ts b/app/api/courrier/[id]/route.ts index 9e06836d..7b1980b2 100644 --- a/app/api/courrier/[id]/route.ts +++ b/app/api/courrier/[id]/route.ts @@ -39,13 +39,8 @@ export async function GET( // Use the email service to fetch the email content const email = await getEmailContent(session.user.id, id, folder); - // Return only what's needed for displaying the email - return NextResponse.json({ - id, - subject: email.subject, - content: email.content, - contentFetched: true - }); + // Return the complete email object instead of just partial data + return NextResponse.json(email); } catch (error: any) { console.error("Error fetching email content:", error); return NextResponse.json( diff --git a/components/email/ComposeEmail.tsx b/components/email/ComposeEmail.tsx index 3f6b3495..c61a3460 100644 --- a/components/email/ComposeEmail.tsx +++ b/components/email/ComposeEmail.tsx @@ -135,6 +135,19 @@ export default function ComposeEmail({ return; } + // Debug log to see the structure of the email object + console.log('Forwarding email object:', JSON.stringify({ + id: initialEmail.id, + subject: initialEmail.subject, + from: initialEmail.from, + to: initialEmail.to, + date: initialEmail.date, + hasContent: !!initialEmail.content, + hasHTML: !!initialEmail.html, + hasText: !!initialEmail.text, + contentFetched: initialEmail.contentFetched + }, null, 2)); + try { // Format subject with Fwd: prefix if needed const subject = initialEmail.subject || "(No subject)";