mail page rest
This commit is contained in:
parent
28612fb39e
commit
9a1ebf7bda
@ -475,6 +475,7 @@ function renderEmailContent(email: Email) {
|
||||
console.log('First 100 chars:', email.body.substring(0, 100));
|
||||
|
||||
try {
|
||||
// First try to parse the full email
|
||||
const parsed = parseFullEmail(email.body);
|
||||
console.log('Parsed content:', {
|
||||
hasText: !!parsed.text,
|
||||
@ -482,8 +483,32 @@ function renderEmailContent(email: Email) {
|
||||
hasAttachments: parsed.attachments.length > 0
|
||||
});
|
||||
|
||||
// Display HTML content if available, otherwise fallback to text
|
||||
const content = parsed.html || parsed.text || decodeMimeContent(email.body);
|
||||
// If parsing failed, try direct content extraction
|
||||
let content = null;
|
||||
if (parsed.html) {
|
||||
content = parsed.html;
|
||||
} else if (parsed.text) {
|
||||
content = parsed.text;
|
||||
} else {
|
||||
// Try to extract content directly from body
|
||||
const htmlMatch = email.body.match(/<html[^>]*>[\s\S]*?<\/html>/i);
|
||||
if (htmlMatch) {
|
||||
content = htmlMatch[0];
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
|
||||
if (!content) {
|
||||
console.log('No content available after all attempts');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user