UserLand Software Home  |  Manila  |  Radio  |  Support  |  News

DocServer

Prev | Next | String Verbs > string.htmlToEmail

string.htmlToEmail

Syntax string.htmlToEmail (htmltext)

Params htmltext is a string containing HTML text to be converted to email text.

Action This verb takes HTML-formatted text and converts it to a format that's easy to read in email. Links are extracted from anchor tags and replaced with numbers in square brackets. All the links appear at the end of the email. Bold text is surrounded in asterisks and italic text enclosed in slashes. Markup is removed. Breaks and paragraphs are converted to single and double carriage returns. Other whitespace is converted.

Returns Text suitable for sending via email.

Example local (s = "Here is some <i>italic text</i>. Some <b>boldface text</b>. <p>Now I would like to <a href=\"http://anonymouse.org/cgi-bin/anon-www.cgi/http://radiodiscuss.userland.com/itsAnOutliner">link</a> to a story that I find interesting.<p>Oh and here's a <a href="http://anonymouse.org/cgi-bin/anon-www.cgi/http://www.scripting.com/wavs/fargo5.wav">sound file</a> that might entertain you.\r\n \r \n \r\n \r\n \r\n \r\n");

tcp.sendmail ("bull\@mancuso.com", "Test message", string.htmlToEmail (s))

Notes This code was developed for the editorial notification feature in Manila. It can be used in many other places now that it is a built-in verb in Frontier and Radio. It's also an interesting example of using xml.compile to get at the attributes of anchor tags in HTML.

See Also tcp.sendMail

string.replaceAll

search.replace

string.patternMatch

xml.compile

Prev | Next | String Verbs > string.htmlToEmail

Anonymization by Anonymouse.org ~ Adverts
Anonymouse better ad-free, faster and with encryption?
X