NS_MsgSACat(&newBody, *body);
if (*body) NS_MsgSACat(&newBody, *body);
mime_insert_all_headers(char            **body,                        MimeHeaders     *headers,                        MSG_ComposeFormat composeFormat,                        char            *mailcharset){  PRBool htmlEdit = (composeFormat == nsIMsgCompFormat::HTML);  char *newBody = NULL;  char *html_tag = PL_strcasestr(*body, "<HTML>");  int i;  if (!headers->done_p)  {    MimeHeaders_build_heads_list(headers);    headers->done_p = PR_TRUE;  }  if (htmlEdit)  {    if (html_tag)    {      *html_tag = 0;      NS_MsgSACopy(&(newBody), *body);      *html_tag = '<';      NS_MsgSACat(&newBody, "<HTML> <BR><BR>");    }    else      NS_MsgSACopy(&(newBody), "<HTML> <BR><BR>");    NS_MsgSACat(&newBody, MimeGetNamedString(MIME_FORWARDED_MESSAGE_HTML_USER_WROTE));    NS_MsgSACat(&newBody, MIME_HEADER_TABLE);  }  else  {    NS_MsgSACopy(&(newBody), MSG_LINEBREAK MSG_LINEBREAK);    NS_MsgSACat(&newBody, MimeGetNamedString(MIME_FORWARDED_MESSAGE_HTML_USER_WROTE));  }  for (i = 0; i < headers->heads_size; i++)  {    char *head = headers->heads[i];    char *end = (i == headers->heads_size-1           ? headers->all_headers + headers->all_headers_fp           : headers->heads[i+1]);    char *colon, *ocolon;    char *contents;    char *name = 0;    char *c2 = 0;    // Hack for BSD Mailbox delimiter.     if (i == 0 && head[0] == 'F' && !nsCRT::strncmp(head, "From ", 5))    {      colon = head + 4;      contents = colon + 1;    }    else    {      /* Find the colon. */      for (colon = head; colon < end; colon++)      if (*colon == ':') break;      if (colon >= end) continue;   /* junk */      /* Back up over whitespace before the colon. */      ocolon = colon;      for (; colon > head && nsCRT::IsAsciiSpace(colon[-1]); colon--)      ;      contents = ocolon + 1;    }    /* Skip over whitespace after colon. */    while (contents <= end && nsCRT::IsAsciiSpace(*contents))    contents++;    /* Take off trailing whitespace... */    while (end > contents && nsCRT::IsAsciiSpace(end[-1]))    end--;    name = (char *)PR_MALLOC(colon - head + 1);    if (!name)       return /* MIME_OUT_OF_MEMORY */;    nsCRT::memcpy(name, head, colon - head);    name[colon - head] = 0;    c2 = (char *)PR_MALLOC(end - contents + 1);    if (!c2)    {      PR_Free(name);      return /* MIME_OUT_OF_MEMORY */;    }    nsCRT::memcpy(c2, contents, end - contents);    c2[end - contents] = 0;        /* Do not reveal bcc recipients when forwarding a message!       See http://bugzilla.mozilla.org/show_bug.cgi?id=41150    */    if (nsCRT::strcasecmp(name, "bcc") != 0)    {      if (htmlEdit) mime_fix_up_html_address(&c2);              mime_intl_insert_message_header_1(&newBody, &c2, name, name, mailcharset,                      htmlEdit);    }    PR_Free(name);    PR_Free(c2);  }  if (htmlEdit)  {    NS_MsgSACat(&newBody, "</TABLE>");    NS_MsgSACat(&newBody, MSG_LINEBREAK "<BR><BR>");    if (html_tag)      NS_MsgSACat(&newBody, html_tag+6);    else      NS_MsgSACat(&newBody, *body);  }  else  {    NS_MsgSACat(&newBody, MSG_LINEBREAK MSG_LINEBREAK);    NS_MsgSACat(&newBody, *body);  }  if (newBody)  {    PR_FREEIF(*body);    *body = newBody;  }}