Get the body of the email message
356364
def get_body(self):
        """"""

        if self.is_multipart():
            # get the plain text version only
            text_parts = [part
                          for part in typed_subpart_iterator(self,
                                                             'text',
                                                             'plain')]
            body = []
            for part in text_parts:
                charset = get_charset(part, get_charset(self))
                body.append(unicode(part.get_payload(decode=True),
                                    charset,
                                    "replace"))

            return u"\n".join(body).strip()

        else:   # if it is not multipart, the payload will be a string
                # representing the message body
            body = unicode(self.get_payload(decode=True),
                           get_charset(self),
                           "replace")
            return body.strip()
1009801
protected function decodeBody()
    {
        if(is_object($this->message)){
            foreach ($this->message->types as $typeMessage) {
                if(is_object($this->message->$typeMessage)){
                    switch ($this->message->$typeMessage->structure->encoding) {
                        case 3:
                            $this->message->$typeMessage->body = imap_base64($this->message->$typeMessage->body);
                            break;
                        case 4:
                            $this->message->$typeMessage->body = imap_qprint($this->message->$typeMessage->body);
                            break;
                    }
                }

                if(is_object($this->message->$typeMessage)){
                    if ($this->message->$typeMessage->charset) {
                        $this->message->$typeMessage->body = $this->convertToUtf8($this->message->$typeMessage->body, $this->message->$typeMessage->charset);
                    }
                }
            }
        }
    }
452076
def _extract_email(data):
    
    ret = ''
    elements = data.get('elements', [])
    if len(elements) > 0:
        ret = elements[0].get('handle~', {}).get('emailAddress', '')
    return ret
638803
public function getBody()
	{
		$number		= count( $this->parts );
		if( !$number )
			return '';

		$innerBoundary	= $this->mimeBoundary.'-1';

		$contents	= array( 'This is a multi-part message in MIME format.');
		$contents[]	= '--'.$this->mimeBoundary;
		$contents[]	= 'Content-Type: multipart/alternative;';
		$contents[]	= ' boundary="'.$innerBoundary.'"'.Net_Mail::$delimiter;
		foreach( $this->parts as $part )
			if( $part instanceof Net_Mail_Body )
				$contents[]	= '--'.$innerBoundary.Net_Mail::$delimiter.$part->render();
		$contents[]	= '--'.$innerBoundary.'--'.Net_Mail::$delimiter;

		foreach( $this->parts as $part )
			if( $part instanceof Net_Mail_Attachment )
				$contents[]	= '--'.$this->mimeBoundary.Net_Mail::$delimiter.$part->render();
		$contents[]	= '--'.$this->mimeBoundary.'--'.Net_Mail::$delimiter;
		return join( Net_Mail::$delimiter, $contents );
	}
1330308
def get_smtp_mail(self):
        
        header = self.get_smtp_header()
        body = self.get_body().replace('\n', '\r\n')
        return header + '\r\n' + body + '\r\n'
478933
def get_email(self, token):
        """"""
        resp = requests.get(self.emails_url,
                            params={'access_token': token.token})
        emails = resp.json().get('values', [])
        email = ''
        try:
            email = emails[0].get('email')
            primary_emails = [e for e in emails if e.get('is_primary', False)]
            email = primary_emails[0].get('email')
        except (IndexError, TypeError, KeyError):
            return ''
        finally:
            return email
633379
def content(self):
        """"""

        if not self.payload:
            return ''

        if self.payload.is_multipart():
            message_bytes = mime_to_bytes(
                self.payload, 0).replace(b'\n', b'\r\n')
            boundary = b'--' + self.payload.get_boundary().encode('utf-8')
            temp = message_bytes.split(boundary)
            temp.pop(0)
            return boundary + boundary.join(temp)
        else:
            content = self.payload.get_payload()
            if isinstance(content, str_cls):
                content = content.encode('utf-8')
            return content
902291
def get_email_link(email, value=None):
    
    if not email:
        return ""
    mailto = 'mailto:{}'.format(email)
    link_value = value and value or email
    return get_link(mailto, link_value)
26783
def to_json(self, include_body=False):
        

        message = {
            'emailId': self.email_id,
            'timestamp': isoformat(self.timestamp),
            'subsystem': self.subsystem,
            'subject': self.subject,
            'sender': self.sender,
            'recipients': self.recipients,
            'uuid': self.uuid,
            'messageHtml': None,
            'messageText': None
        }

        if include_body:
            message['messageHtml'] = self.message_html
            message['messageText'] = self.message_text

        return message
493109
protected function getBody()
    {
        $data = $this->form->data();

        unset($data[self::EMAIL_KEY]);
        unset($data[self::RECEIVE_COPY_KEY]);
        $body = '';
        foreach ($data as $key => $value) {
            if (is_array($value)) {
                $value = implode(', ', array_filter($value, function ($i) {
                    return $i !== '';
                }));
            }

            $body .= ucfirst($key).': '.$value."\n\n";
        }

        return $body;
    }
844319
def parse(self):
        

        if not self.message:
            return self

        # reset and start parsing
        self._reset()
        parts = []  # Normal parts plus defects

        # walk all mail parts to search defects
        for p in self.message.walk():
            part_content_type = p.get_content_type()
            self._append_defects(p, part_content_type)
            parts.append(p)

        # If defects are in epilogue defects get epilogue
        if self.defects_categories & EPILOGUE_DEFECTS:
            log.debug("Found defects in emails")
            epilogue = find_between(
                self.message.epilogue,
                "{}".format("--" + self.message.get_boundary()),
                "{}".format("--" + self.message.get_boundary() + "--"))

            try:
                p = email.message_from_string(epilogue)
                parts.append(p)
            except TypeError:
                log.debug("Failed to get epilogue part for TypeError")
            except Exception:
                log.error("Failed to get epilogue part. Check raw mail.")

        # walk all mail parts
        for i, p in enumerate(parts):
            if not p.is_multipart():
                filename = decode_header_part(p.get_filename())
                charset = p.get_content_charset('utf-8')
                charset_raw = p.get_content_charset()
                log.debug("Charset {!r} part {!r}".format(charset, i))

                if filename:
                    log.debug("Email part {!r} is an attachment".format(i))
                    log.debug("Filename {!r} part {!r}".format(filename, i))
                    binary = False
                    mail_content_type = ported_string(p.get_content_type())
                    log.debug("Mail content type {!r} part {!r}".format(
                        mail_content_type, i))
                    transfer_encoding = ported_string(
                        p.get('content-transfer-encoding', '')).lower()
                    log.debug("Transfer encoding {!r} part {!r}".format(
                        transfer_encoding, i))
                    content_id = ported_string(p.get('content-id'))
                    log.debug("content-id {!r} part {!r}".format(
                        content_id, i))

                    if transfer_encoding == "base64" or (
                       transfer_encoding == "quoted-\
                       printable" and "application" in mail_content_type):

                        payload = p.get_payload(decode=False)
                        binary = True
                        log.debug("Filename {!r} part {!r} is binary".format(
                            filename, i))
                    else:
                        payload = ported_string(
                            p.get_payload(decode=True), encoding=charset)
                        log.debug(
                            "Filename {!r} part {!r} is not binary".format(
                                filename, i))

                    self._attachments.append({
                        "filename": filename,
                        "payload": payload,
                        "binary": binary,
                        "mail_content_type": mail_content_type,
                        "content-id": content_id,
                        "charset": charset_raw,
                        "content_transfer_encoding": transfer_encoding})
                else:
                    log.debug("Email part {!r} is not an attachment".format(i))
                    payload = ported_string(
                        p.get_payload(decode=True), encoding=charset)
                    if payload:
                        if p.get_content_subtype() == 'html':
                            self._text_html.append(payload)
                        else:
                            self._text_plain.append(payload)
        else:
            # Parsed object mail with all parts
            self._mail = self._make_mail()

            # Parsed object mail with mains parts
            self._mail_partial = self._make_mail(complete=False)
849853
def get_email(self):
        
        api_url = self.api_url + "/events/public"
        api_content = GithubRawApi(
            api_url,
            get_api_content_now=True
        ).api_content

        for event in api_content:
            if event["type"] == "PushEvent":
                return event["payload"]["commits"][0]["author"]["email"]
147447
public String readBodyAsString() {
        Charset charset = readCharset();
        byte[] bodyContent = message.getBodyContent();
        return new String(bodyContent, charset);
    }
507971
def body(self):
        """"""

        if self._decoded_body == None:
            # Try to decode the JSON body. But raise an error if the
            # content-type is unexpected, or the JSON is invalid.

            raw_content_type = self.request.headers.get("content-type") or ""
            content_type = raw_content_type.split(";")[0].strip().lower()

            if content_type == "application/json":
                try:
                    self._decoded_body = escape.json_decode(self.request.body)
                except:
                    raise oz.json_api.ApiError("Bad JSON body")
            else:
                raise oz.json_api.ApiError("JSON body expected")

        return self._decoded_body
148768
function get_message($uid, $raw = null)
    {
        if ( $this->stream !== null && $this->stream !== false ) {

            if ( $raw === null ) {
                $raw = $this->options['raw'];
            }

            $raw_header  = imap_fetchheader($this->stream, $uid, FT_UID);
            $raw_body    = imap_body($this->stream, $uid, FT_UID);
            $raw_message = $raw_header . $raw_body;

            if ( $raw ) {
                return $raw_message;
            } else {
                if ( class_exists('Email_Parser') ) {
                    return new Email_Parser($raw_message);
                }
            }

        }
    }
1261448
public MailBuilder content(Body body) {
        return text(body.text()).html(body.html());
    }
854712
def emails(text):
    ''''''
    return imap(lambda m: m.group(0).lower(), REGEX_EMAIL.finditer(text))