This is more a tip than a question, but I had to struggle with it, and didn’t find anything online about how to do it, so here goes:
When you copy text from a browser, it the clipboard contains a record with the text you copied as “«class HTML»”, “«class utf8»”, “«class ut16»”, string, and unicode text. You can view the record by running the code:
return the clipboard as record
The problem is that the HTML data - the data that contains the HTML tags as well as the text that was copied - is binary data. To create an Applescript variable with actual HTML in it, you will need to write the clipboard data to a text file and then read it back into a variable.
set thex to «class HTML» of (the clipboard as record)
-- This will trigger an error if you've copied something other than HTML data
set f to (path to "temp" from user domain as text) & "temp.txt"
-- Writes to a file named "temp.txt" in "Macintosh HD:Users:[userid]:Library:Caches:TemporaryItems:temp.txt"
set newFile to open for access file f with write permission
set eof of newFile to 0
write thex to newFile
close access newFile
set newFile to open for access file f
set theHTML to read newFile
It doesn’t, it has «class weba». You can switch out «class weba» for «class HTML», and get a variable with code. The code returned from «class weba» has styles included in it, whereas «class HTML» data just returns HTML.
I’ve used this for some time. I don’t know about Postbox, but this code will produce a link you can paste into any RTF-aware application.
-- http://macscripter.net/viewtopic.php?id=26498 post #13
on createRTFlink(linkURL, linkTitle)
set HTML to "<font size=4><a href=\"" & linkURL & "\">" & linkTitle & "</a></font>"
do shell script "echo " & quoted form of HTML & " | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf"
end createRTFlink
set strCMD to "osascript -e 'the clipboard as «class HTML»' | perl -ne 'print chr foreach unpack(\"C*\",pack(\"H*\",substr($_,11,-3)))'"
set strHTML to (do shell script strCMD)