Converting html mail to plain text - Mozilla

This is a discussion on Converting html mail to plain text - Mozilla ; Hi guys, I want to know how the HTML mail body from the compose window is converted to plain text when the message is sent because I need to do this for my extension. Thanks. Regards, Rodica __________________________________________________ __________________________________ Luggage? ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Converting html mail to plain text

  1. Converting html mail to plain text

    Hi guys,

    I want to know how the HTML mail body from the compose
    window is converted to plain text when the message is
    sent because I need to do this for my extension.
    Thanks.

    Regards,
    Rodica


    __________________________________________________ __________________________________
    Luggage? GPS? Comic books?
    Check out fitting gifts for grads at Yahoo! Search
    http://search.yahoo.com/search?fr=on...on+gifts&cs=bz

  2. Re: Converting html mail to plain text

    Fulg de Nea pisze:
    > Hi guys,
    >
    > I want to know how the HTML mail body from the compose
    > window is converted to plain text when the message is
    > sent because I need to do this for my extension.
    > Thanks.
    >
    > Regards,
    > Rodica
    >
    >
    > __________________________________________________ __________________________________
    > Luggage? GPS? Comic books?
    > Check out fitting gifts for grads at Yahoo! Search
    > http://search.yahoo.com/search?fr=on...on+gifts&cs=bz


    Function...

    gMsgCompose.editor.QueryInterface(Components.inter faces.nsIEditor)
    .outputToString('text/plain', FLAGS);

    ....is used, where FLAGS is a unsigned integer.

    Bellow are meaning and values of flags (i post it because i spent some
    time on google to find it...). Flags may be used together, using bitwise
    OR (ex: OutputPreformatted + OutputLFLineBreak => "16 | 1024").

    For You, most important flag is "OutputFormatFlowed".



    * Output only the selection (as opposed to the whole document).
    enum { OutputSelectionOnly = 1U };

    * Plaintext output: Convert html to plaintext that looks like the html.
    * Implies wrap (except inside
    ), since html wraps.
    * HTML output: always do prettyprinting, ignoring existing formatting.
    * (Probably not well tested for HTML output.)
    enum { OutputFormatted = 2U };

    * Don't do prettyprinting of HTML. Don't do any wrapping that's not in
    * the existing HTML source. This option overrides OutputFormatted if both
    * are set.
    * @note This option does not affect entity conversion.
    enum { OutputRaw = 4U };

    * Do not print html head tags.
    enum { OutputBodyOnly = 8U };

    * Wrap even if we're not doing formatted output (e.g. for text fields)
    * XXXbz this doesn't seem to be used by all serializers... document? How
    * does this interact with
    * OutputFormatted/OutputRaw/OutputWrap/OutputFormatFlowed?
    enum { OutputPreformatted = 16U };

    * Output as though the content is preformatted
    * (e.g. maybe it's wrapped in a MOZ_PRE or MOZ_PRE_WRAP style tag)
    * XXXbz this doesn't seem to be used by all serializers... document? How
    * does this interact with
    * OutputFormatted/OutputRaw/OutputPreformatted/OutputFormatFlowed?
    enum { OutputWrap = 32U };

    * Output for format flowed (RFC 2646). This is used when converting
    * to text for mail sending. This differs just slightly
    * but in an important way from normal formatted, and that is that
    * lines are space stuffed. This can't (correctly) be done later.
    * XXXbz this doesn't seem to be used by all serializers... document? *
    does this interact with
    * OutputFormatted/OutputRaw/OutputPreformatted/OutputWrap?
    enum { OutputFormatFlowed = 64U };

    * Convert links, image src, and script src to absolute URLs when possible
    enum { OutputAbsoluteLinks = 128U };

    * Attempt to encode entities standardized at W3C (HTML, MathML, etc).
    * This is a catch-all flag for documents with mixed contents. Beware of
    * interoperability issues. See below for other flags which might likely
    * do what you want.
    enum { OutputEncodeW3CEntities = 256U };

    * LineBreak processing: if this flag is set than CR line breaks will
    * be written. If neither this nor OutputLFLineBreak is set, then we
    * will use platform line breaks. The combination of the two flags will
    * cause CRLF line breaks to be written.
    enum { OutputCRLineBreak = 512U };

    * LineBreak processing: if this flag is set than LF line breaks will
    * be written. If neither this nor OutputCRLineBreak is set, then we
    * will use platform line breaks. The combination of the two flags will
    * cause CRLF line breaks to be written.
    enum { OutputLFLineBreak = 1024U };

    * Output the content of noscript elements (only for serializing
    * to plaintext).
    enum { OutputNoScriptContent = 2048U };

    * Output the content of noframes elements (only for serializing
    * to plaintext).
    enum { OutputNoFramesContent = 4096U };

    * Don't allow any formatting nodes (e.g.
    , ) inside a
    .
    * This is used primarily by mail.
    enum { OutputNoFormattingInPre = 8192U };

    * Encode entities when outputting to a string.
    * E.g. If set, we'll output   if clear, we'll output 0xa0.
    * The basic set is just   & < > " for interoperability
    * with older products that don't support α and friends.
    enum { OutputEncodeBasicEntities = 16384U };

    * Encode entities when outputting to a string.
    * The Latin1 entity set additionally includes 8bit accented letters
    * between 128 and 255.
    enum { OutputEncodeLatin1Entities = 32768U };

    * Encode entities when outputting to a string.
    * The HTML entity set additionally includes accented letters, greek
    * letters, and other special markup symbols as defined in HTML4.
    enum { OutputEncodeHTMLEntities = 65536U };

    * Normally   is replaced with a space character when
    * encoding data as plain text, set this flag if that's
    * not desired.
    enum { OutputPersistNBSP = 131072U };

    --
    Arivald