Here is a solution, though it's a bit convoluted:
1. Navigate to the gmail message thread of interest in your browser
2. Run the following JS in the developer console (or better, programmatically with Applescript, if using Safari, or some other browser automation program like WWW::Mechanize::Chrome) to get the "legacy" thread id:
document.querySelector('[data-legacy-thread-id]').getAttribute('data-legacy-thread-id')
Once you get the thread id, you then need to convert it to a decimal number.
my $dec_num_id = sprintf("%d", hex($thread_id));
3. Now that you have obtained the thread id, you can use the Perl Mail::IMAPClient cpan module to obtain the messages in the thread by searching on the thread id:
use Mail::IMAPClient;
my $imap = Mail::IMAPClient->new(
Server => 'imap.gmail.com',
User => 'me',
Password => 'blah',
Ssl => 1,
Uid => 1,
);
my $folders = $imap->select('INBOX');
my $msgs = $imap->search("X-GM-THRID", $dec_num_id);
foreach my $msg (@$msgs) {
my $msg_st = $imap->message_string($msg);
# slice and dice messages with modules listed below
}
4. Now you can use cpan modules like Email::MIME and Email::MIME::Attachment::Stripper and Email::MIME::Encodings to parse the emails in $msgs and decode them as necessary.
|