ConvertBufToPlainText(nsString &aConBuf)
ConvertBufToPlainText(nsString &aConBuf, PRBool formatflowed )
ConvertBufToPlainText(nsString &aConBuf){  nsresult    rv;  nsString    convertedText;  nsIParser   *parser;  if (aConBuf.IsEmpty())    return NS_OK;  static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);  static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);   rv = nsComponentManager::CreateInstance(kCParserCID, nsnull,                                           kCParserIID, (void **)&parser);  if (NS_SUCCEEDED(rv) && parser)  {    nsHTMLToTXTSinkStream     *sink = nsnull;    PRUint32 converterFlags = 0;    PRUint32 wrapWidth = 72;        converterFlags |= nsIDocumentEncoder::OutputFormatted;    nsresult rv2;    NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv2);    if (NS_SUCCEEDED(rv2))    {      PRBool sendflowed = PR_TRUE;      rv2=prefs->GetBoolPref("mailnews.send_plaintext_flowed", &sendflowed);      if(NS_FAILED(rv2) || sendflowed) // Unless explicitly forbidden...        converterFlags |= nsIDocumentEncoder::OutputFormatFlowed;    }        rv = NS_New_HTMLToTXT_SinkStream((nsIHTMLContentSink **)&sink, &convertedText, wrapWidth, converterFlags);    if (sink && NS_SUCCEEDED(rv))     {          sink->DoFragment(PR_TRUE);        parser->SetContentSink(sink);        nsIDTD* dtd = nsnull;        rv = NS_NewNavHTMLDTD(&dtd);        if (NS_SUCCEEDED(rv))         {          parser->RegisterDTD(dtd);          rv = parser->Parse(aConBuf, 0, NS_ConvertASCIItoUCS2("text/html"), PR_FALSE, PR_TRUE);                   }        NS_IF_RELEASE(dtd);        NS_IF_RELEASE(sink);    }    NS_RELEASE(parser);    //    // Now if we get here, we need to get from ASCII text to     // UTF-8 format or there is a problem downstream...    //    if (NS_SUCCEEDED(rv))    {      aConBuf = convertedText;    }  }  return rv;}