+ /** set body to represent the given part
+ * @param partid INT index of the part in messages
+ */
+ function set_body_to_part($partid)
+ {
+ global $banana;
+
+ if (count($this->messages) == 0) {
+ return false;
+ }
+
+ $local_header = $this->messages[$partid]['headers'];
+ $this->body = $this->messages[$partid]['body'];
+ foreach ($banana->parse_hdr as $hdr) {
+ if (isset($local_header[$hdr])) {
+ $this->headers[$hdr] = $local_header[$hdr];
+ }
+ }
+
+ if (preg_match('!charset=([^;]*)\s*(;|$)!', $this->headers['content-type'], $matches)) {
+ $this->body = iconv($matches[1], 'utf-8', $this->body);
+ } else {
+ $this->body = utf8_encode($this->body);
+ }
+ return true;
+ }
+