private function process_message_data(
            \Horde_Imap_Client_Data_Envelope $envelope,
            \Horde_Imap_Client_Data_Fetch $basemessagedata,
            $messageid) {

        // Get the current mailbox.
        $mailbox = $this->get_mailbox();

        // We need the structure at various points below.
        $structure = $basemessagedata->getStructure();

        // Now fetch the rest of the message content.
        $query = new \Horde_Imap_Client_Fetch_Query();
        $query->imapDate();

        // Fetch the message header.
        $query->headerText();

        // Retrieve the message with the above components.
        $messagedata = $this->client->fetch($mailbox, $query, array('ids' => $messageid))->first();

        if (!$messagedata) {
            // Message was not found! Somehow it has been removed or is no longer returned.
            return null;
        }

        // The message ID should always be in the first part.
        $data = new \stdClass();
        $data->messageid = $messagedata->getHeaderText(0, \Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->getValue('Message-ID');
        $data->subject = $envelope->subject;
        $data->timestamp = $messagedata->getImapDate()->__toString();
        $data->envelope = $envelope;
        $data->data = $this->addressmanager->get_data();
        $data->headers = $messagedata->getHeaderText();

        $this->currentmessagedata = $data;

        return $this->currentmessagedata;
    }