Skip to content

Commit

Permalink
read text body from mail message and display
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Nov 8, 2012
1 parent 3d226d6 commit 348e564
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
3 changes: 2 additions & 1 deletion mail/js/mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Mail = {
clone.removeClass('template');

clone.data('message_id', message.id);
clone.attr('data-message-id', message.id);
if (message.flags['unseen']) {
clone.addClass('unseen');
}
Expand Down Expand Up @@ -112,7 +113,7 @@ Mail = {
Mail.UI.closeMessage();

// Find the correct message
message = $('#mail_messages tr[data-message_id="' + message_id + '"]');
message = $('#mail_messages tr[data-message-id="' + message_id + '"]');
message.after(jsondata.data);

// Set current Message as active
Expand Down
29 changes: 26 additions & 3 deletions mail/lib/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private function getmsg() {
$fetch_query = new \Horde_Imap_Client_Fetch_Query();
$fetch_query->envelope();
// $fetch_query->fullText();
$fetch_query->bodyText();
// $fetch_query->bodyText();
//$fetch_query->bodyPart(1);
$fetch_query->structure();
$fetch_query->flags();
Expand All @@ -118,8 +118,31 @@ private function getmsg() {
$headers = $this->conn->fetch($this->folder_id, $fetch_query, array('ids' => $ids));
$this->fetch = $headers[$this->message_id];

//$headers[$this->message_id]->get
$this->plainmsg = $headers[$this->message_id]->getBodyText();
// stupid: return all
// $this->plainmsg = $headers[$this->message_id]->getBodyText();

// analyse the body part
$structure = $this->fetch->getStructure();
//
// TODO: handle nulls
//
if ($structure->findBody() != null) {
// get the body from the server
$partId = $structure->findBody();
$fetch_query->bodyPart($partId);
$headers = $this->conn->fetch($this->folder_id, $fetch_query, array('ids' => $ids));
$this->fetch = $headers[$this->message_id];

$structure = $this->fetch->getStructure();
$this->plainmsg = $structure->getPart($structure->findBody())->getContents();
$this->plainmsg = $this->fetch->getBodyPart($partId);
}

// debugging below
$structure_type = $structure->getType();


// if ($structure->)
//
// // HEADER
// $this->header = $this->conn->fetchHeader($this->folder_id, $this->message_id);
Expand Down
2 changes: 1 addition & 1 deletion mail/templates/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>
<div id="rightcontent" class="rightcontent">
<table id="mail_messages">
<tr class="template mail_message_summary">
<tr class="template mail_message_summary" data-message-id="0">
<td class="mail_message_summary_from"></td>
<td class="mail_message_summary_subject"></td>
<td class="mail_message_summary_date"></td>
Expand Down

0 comments on commit 348e564

Please sign in to comment.