Re: Getting content of an HTML message in Mail
Re: Getting content of an HTML message in Mail
- Subject: Re: Getting content of an HTML message in Mail
- From: Christian Boyce <email@hidden>
- Date: Mon, 13 Dec 2004 00:57:33 -0800
Thanks for this. I looked at your Mail scripts page and it's terrific.
One of these days (months) I'll dive into Perl and come back and fix my
script. For now, since I know nothing of Perl, I prefer to go with
AppleScript so I can change things as the need arises.
I ended up using a long list of "replaces" to strip away the HTML
codes, using text item delimiters (searching for "<br>", "</font>"
etc.). Incredibly fast. As close to instantaneous as I could hope for.
Thirty-nine calls to a search-and-replace handler using text item
delimiters took less than 1 second on an accelerated G4 Cube (operating
on a chunk of text more than 5,000 characters long). That's plenty
fast.
Thanks also for letting me know that I wasn't going crazy over here. I
thought I knew how to get the content of a Mail message (and I do)-- so
when it didn't work I was really confused. Thanks to your message I
stopped beating my head against the wall and tried another method (and
gained a real appreciation for text item delimiters!).
cb
I am trying to get the content of a selected message. The message is
formatted with HTML.
[...]
I get the_subject just fine, but the_content shows "?" rather than
the content of the message.
I am able to make this work (getting "source" rather than "content"):
[...]
but this gives me a lot of formatting to wade through (all I want is
the information, not the formatting). Is there a way for me to get
just the text, without the formatting, if the message is HTML?
Oh yes, the joys of AS implementation errors in Mail;-) This actually
used to work as intended in 10.2 (you would get the content of the
plain text alternative) but broke in 10.3.0 and has not been fixed -
maybe even more people need to submit this bug to Apple to get it
fixed...
The only way of dealing with this currently is indeed getting the
message source and wading through it all the extract the information
you want - Perl is your friend here!
I have written a parser for mail messages in Perl (using HTML::Parser
and Mail::Tools from CPAN) which can be implemented in an AppleScript -
I do this in the "Export Messages" script of "Mail Scripts". You might
want to take a look at the source code which is available from my web
page:
http://homepage.mac.com/aamann/
Andreas Amann
--
Christian Boyce
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden