'Retrieve message with UID from the IMAP server (incl body).  Also
gets Gmail labels and embeds them into the message.
:returns: the message body or throws and OfflineImapError
(probably severity MESSAGE) if e.g. no message with
this UID could be found.'

def getmessage(self, uid):

    data = self._fetch_from_imap(str(uid), self.retrycount)
    body = data[0][1].replace('\r\n', '\n')
    if self.synclabels:
        m = re.search('X-GM-LABELS\\s*\\(([^\\)]*)\\)', data[0][0])
        if m:
            labels = set([imaputil.dequote(lb) for lb in imaputil.imapsplit(m.group(1))])
        else:
            labels = set()
        labels = (labels - self.ignorelabels)
        labels_str = imaputil.format_labels_string(self.labelsheader, sorted(labels))
        body = self.deletemessageheaders(body, self.labelsheader)
        body = self.addmessageheader(body, '\n', self.labelsheader, labels_str)
    if (len(body) > 200):
        dbg_output = ('%s...%s' % (str(body)[:150], str(body)[(-50):]))
    else:
        dbg_output = body
    self.ui.debug('imap', ("Returned    object    from    fetching    %d:    '%s'" % (uid, dbg_output)))
    return body
