107 lines
No EOL
4.5 KiB
JavaScript
107 lines
No EOL
4.5 KiB
JavaScript
// test_parser.js
|
|
// A simple test script to demonstrate how to use the email parser
|
|
|
|
// Import the email parser functions
|
|
// Note: In a browser context, you would use importScripts instead
|
|
const { parseMimeEmail, extractEmailThread } = require('./email_parser.js');
|
|
|
|
// Example MIME email content
|
|
const mimeContent = `MIME-Version: 1.0
|
|
Date: Fri, 2 May 2025 13:40:14 -0700
|
|
References: <CALhcmpYY6Fr_EiNK=9j_inFQEe4PcDDcmkiWyPEigqWs+WCrzg@mail.gmail.com>
|
|
<ins-u-1-01969293-9d6e-7191-8ae4-ebacf5dd2816@newfrontierinc.com>
|
|
In-Reply-To: <ins-u-1-01969293-9d6e-7191-8ae4-ebacf5dd2816@newfrontierinc.com>
|
|
Bcc: 45972187@bcc.hubspot.com
|
|
Message-ID: <CANVF1TOomXe9ykviUG2SScd5e0yFsdhHatt9FCR8jtbmwDFd-A@mail.gmail.com>
|
|
Subject: Re: Re: Funding marketing agencies
|
|
From: Curtis Boortz <curtis@newfrontierinc.com>
|
|
To: kirk@219group.com
|
|
Cc: Maria Zandonai <maria@newfrontierinc.com>
|
|
Content-Type: multipart/alternative; boundary="0000000000005794a106342d2806"
|
|
|
|
--0000000000005794a106342d2806
|
|
Content-Type: text/plain; charset="UTF-8"
|
|
Content-Transfer-Encoding: quoted-printable
|
|
|
|
Hi Kirk,
|
|
|
|
Here with Maria, just jumping in to support. Yours is a unique case, and
|
|
this is on us for not making it clear sooner, but the Bolt loan has
|
|
industry restrictions around marketing agencies, so they aren't the best
|
|
option here.
|
|
|
|
That said, we work with another SBA bank, Newity, that offers a very
|
|
similar product; the main difference is that they *can* work with marketing
|
|
agencies.
|
|
|
|
If that sounds alright with you, I'm happy to move this forward. The next
|
|
step would be filling out a quick 5-minute application, after which we can
|
|
get some hard numbers for you. Let me know what you think.
|
|
|
|
Best,
|
|
Curtis
|
|
|
|
--0000000000005794a106342d2806
|
|
Content-Type: text/html; charset="UTF-8"
|
|
Content-Transfer-Encoding: quoted-printable
|
|
|
|
<div dir=3D"ltr"><div dir=3D"ltr">Hi Kirk,<br><br>Here with Maria, just jum=
|
|
ping in to support. Yours is a unique case, and this is on us for not makin=
|
|
g it clear sooner, but the Bolt loan has industry restrictions around marke=
|
|
ting agencies, so they aren't the best option here.<br><br>That said, w=
|
|
e work with another=C2=A0SBA bank, Newity, that offers a very similar produ=
|
|
ct; the main difference is that they <i>can</i>=C2=A0work with marketing ag=
|
|
encies.=C2=A0<br><br>If that sounds alright with you, I'm happy to move=
|
|
this forward. The next step would be filling out a quick 5-minute applicat=
|
|
ion, after which we can get some hard numbers for you. Let me know what you=
|
|
think.<br><br>Best,<div>Curtis<br><br></div></div></div>
|
|
|
|
--0000000000005794a106342d2806--`;
|
|
|
|
// Parse the MIME email
|
|
console.log('Parsing MIME email...');
|
|
const parsedEmail = parseMimeEmail(mimeContent);
|
|
console.log('Parsed email headers:', parsedEmail.headers);
|
|
console.log('Text content:', parsedEmail.textContent);
|
|
console.log('HTML content:', parsedEmail.htmlContent);
|
|
|
|
// Extract the email thread
|
|
console.log('\nExtracting email thread...');
|
|
const emailThread = extractEmailThread(mimeContent);
|
|
console.log('Subject:', emailThread.subject);
|
|
console.log('From:', emailThread.sender.name, '<' + emailThread.sender.email + '>');
|
|
console.log('To:', emailThread.recipient.name, '<' + emailThread.recipient.email + '>');
|
|
console.log('Content:', emailThread.content);
|
|
|
|
// Usage in a browser context:
|
|
/*
|
|
// In a content script:
|
|
document.getElementById('parse-button').addEventListener('click', async () => {
|
|
const mimeContent = document.getElementById('mime-input').value;
|
|
try {
|
|
const emailData = await parseMimeEmail(mimeContent);
|
|
console.log('Parsed email:', emailData);
|
|
document.getElementById('result').textContent = JSON.stringify(emailData, null, 2);
|
|
} catch (error) {
|
|
console.error('Failed to parse email:', error);
|
|
document.getElementById('result').textContent = 'Error: ' + error.message;
|
|
}
|
|
});
|
|
|
|
// Or using the background script via message passing:
|
|
document.getElementById('parse-button').addEventListener('click', async () => {
|
|
const mimeContent = document.getElementById('mime-input').value;
|
|
chrome.runtime.sendMessage({
|
|
action: 'parseMimeEmail',
|
|
mimeContent
|
|
}, response => {
|
|
if (response && response.success) {
|
|
console.log('Parsed email:', response.emailData);
|
|
document.getElementById('result').textContent = JSON.stringify(response.emailData, null, 2);
|
|
} else {
|
|
console.error('Failed to parse email:', response.error);
|
|
document.getElementById('result').textContent = 'Error: ' + response.error;
|
|
}
|
|
});
|
|
});
|
|
*/
|