MozillaZine


getMsgTextFromStream: inserting breaklines problem

Talk about add-ons and extension development.
morat
 
Posts: 4863
Joined: February 3rd, 2009, 6:29 pm

Post Posted July 9th, 2021, 9:10 am

user2018 wrote:I would like to retrieve the body text without the headers.

morat wrote:code snippet based on the |IETstoreBody| function

Try this:

Code: Select all
  text = text.replace("$%$%$", ":");
+ for (var i = 0; i < 9; i++) text = text.replace(/^.*\r\n/, "");
  var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"].
    getService(Components.interfaces.nsIClipboardHelper);

user2018
 
Posts: 106
Joined: September 23rd, 2018, 11:07 am

Post Posted July 10th, 2021, 2:45 am

Thanks a lot!! This seems to work now. I am not sure about the intention behind the following code:

Code: Select all
    if (os.indexOf("win") > -1)
      text = strValue.replace(/(.+\r\n?)*/, "");
    else
      text = strValue.replace(/(.+\n?)*/, "");
    text = text.replace(/\r?\n+/g, "\r\n");
    text = text.replace(/^(\r\n)/g, "");
    text = text.replace(/(\r\n)$/g, "");


I have commented it, as it seems to remove empty lines within the message body, that I would like to preserve (as they were in the original message).

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 3 guests