1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { MockRe2 } from "https://esm.town/v/andreterron/MockRe2";
import EmailForwardParser from "npm:@andreterron/email-forward-parser@1.5.7";
const parser = new EmailForwardParser(MockRe2);
interface EmailAddress {
address: string | undefined;
name: string | undefined;
}
export function parseForwardedEmail(body: string, subject: string): {
forwarded: boolean;
message: string | null;
email: {
body: string | undefined;
from: EmailAddress;
to: EmailAddress[] | undefined;
cc: EmailAddress[] | undefined;
subject: string | undefined;
date: string | undefined;
};
} {
return parser.read(body, subject);
}