Re: Decoding Quoted-Printable in (Apple) Mail Message Source
Re: Decoding Quoted-Printable in (Apple) Mail Message Source
- Subject: Re: Decoding Quoted-Printable in (Apple) Mail Message Source
- From: Takaaki Naganoya <email@hidden>
- Date: Tue, 14 Nov 2017 20:16:55 +0900
Now we can easily handle Mail.app message with AppleScript by using MailCore2
framework.
https://github.com/MailCore/mailcore2
—Parse Mail.app’s eml files by AppleScript
http://piyocast.com/as/archives/4406
—Prepare Mail.app’s eml files by AppleScript
http://piyocast.com/as/archives/4397
—Decode attachment files from Mail.app’s eml file
http://piyocast.com/as/archives/4400
--
Takaaki Naganoya
email@hidden
http://piyocast.com/as/
> 2017/11/14 18:49、Christopher Stone <email@hidden>のメール:
>
> Hey Folks,
>
> I've been trying to find a well established method of decoding
> quoted-printable for years, because the source of Mail.app messages is often
> a real mess and hard to parse. (Parsing becomes much more manageable if you
> can decode QP first.)
>
> I'm still far from being an advanced Perl user, but I keep tinkering and
> slowly improving my fluency.
>
> That said — it occurred to me that as mature as Perl is — and how often it's
> been used to run Internet processes — it would be strange if a module for
> managing encodings didn't exist.
>
> After some detective work I found such a module and learned how to make it
> sit (still can't get it to roll-over though).
>
> (The Perl module in question should be pre-installed in any recent version of
> macOS.)
>
> The appended script makes it much easier to scarf embedded URLs and other
> data out of (Apple) Mail messages.
>
> Enjoy.
>
> --
> Take Care,
> Chris
>
> -------------------------------------------------------------------------------------------
> # Auth: Christopher Stone
> # dCre: 2017/11/13 22:40
> # dMod: 2017/11/13 22:55
> # Appl: Mail
> # Task: Extract the source of the selected message — and decode any
> quoted-printable encoding.
> # Libs: Requires the Perl module MIME::QuotedPrint from MIME::Tools
> (installed by default on macOS).
> # Osax: None
> # Tags: @Applescript, @Script, @Extract, @Source, @Selected, @Message,
> @Decode, @Quoted-printable, @Encoding
> -------------------------------------------------------------------------------------------
>
> set perlScript to text 2 thru -1 of "
> #!/usr/bin/perl -sw
> use MIME::QuotedPrint;
>
> my ($decodedStr, $messageSource, $shCMD);
>
> $shCMD = qq(
> osascript -e '
> # Get Message Source from selected message in Mail.app
> tell application \"Mail\"
> set selectedMessage to item 1 of (get selection)
> set messageSource to (get source of selectedMessage)
> return messageSource
> end tell
> ');
>
> $messageSource = `$shCMD`;
> $decodedStr = decode_qp($messageSource);
>
> print $decodedStr;
>
> "
>
> set decodedMessageSource to do shell script "perl -f <<< " & quoted form of
> perlScript
>
> -------------------------------------------------------------------------------------------
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden