diff --git a/app/api/courrier/route.ts b/app/api/courrier/route.ts index bd03a8de..e5ab7b8b 100644 --- a/app/api/courrier/route.ts +++ b/app/api/courrier/route.ts @@ -77,10 +77,8 @@ export async function GET(request: Request) { envelope: true, flags: true, bodyStructure: true, - bodyParts: [ - 'text/plain', - 'text/html' - ] + source: true, // Get the full email source + bodyParts: ['text/plain', 'text/html'] // Get both text and HTML content }); for await (const message of messages) { @@ -88,8 +86,7 @@ export async function GET(request: Request) { let content = ''; if (message.bodyParts) { // Prefer HTML content if available - content = message.bodyParts.get('text/html')?.toString() || - message.bodyParts.get('text/plain')?.toString() || ''; + content = message.bodyParts.get('text/html')?.toString() || message.bodyParts.get('text/plain')?.toString() || ''; } result.push({ @@ -104,7 +101,8 @@ export async function GET(request: Request) { folder: mailbox.path, hasAttachments: message.bodyStructure?.type === 'multipart', flags: Array.from(message.flags), - content: content + content: content, + source: message.source?.toString() || '' // Include full email source for parsing }); }