public function encodeMimeMultipart(array $bodyPartContents)
    {
        $count         = count($bodyPartContents);
        $mimeType      = Resources::MULTIPART_MIXED_TYPE;
        $batchGuid     = Utilities::getGuid();
        $batchId       = sprintf('batch_%s', $batchGuid);
        $contentType1  = array('content_type' => "$mimeType");
        $changeSetGuid = Utilities::getGuid();
        $changeSetId   = sprintf('changeset_%s', $changeSetGuid);
        $contentType2  = array('content_type' => "$mimeType; boundary=$changeSetId");
        $options       = array(
            'encoding'     => 'binary',
            'content_type' => Resources::HTTP_TYPE
        );

        $eof = "\r\n";

        $result            = array();
        $result['body']    = Resources::EMPTY_STRING;
        $result['headers'] = array();

        $batchBody         =& $result['body'];
        $batchHeaders      =& $result['headers'];

        $batchHeaders['Content-Type'] = $mimeType . "; $eof boundary=\"$batchId\"";

        $batchBody .= "--" . $batchId . $eof;
        $batchBody .= "Content-Type: $mimeType; boundary=\"$changeSetId\"" . $eof;

        $batchBody .= $eof;
        for ($i = 0; $i < count($bodyPartContents); $i++) {
            $batchBody .= "--" . $changeSetId . $eof;

            $batchBody .= "Content-Transfer-Encoding: binary" . $eof;
            $batchBody .= "Content-Type: " . Resources::HTTP_TYPE . $eof;

            $batchBody .= $eof . $bodyPartContents[$i] . $eof;
        }
        $batchBody .= "--" . $changeSetId . "--" . $eof;
        $batchBody .= $eof;
        $batchBody .= "--" . $batchId . "--" . $eof;

        return $result;
    }
public function encodeMimeMultipart(array $bodyPartContents)
    {
        $count         = count($bodyPartContents);
        $mimeType      = Resources::MULTIPART_MIXED_TYPE;
        $batchGuid     = Utilities::getGuid();
        $batchId       = sprintf('batch_%s', $batchGuid);
        $contentType1  = array('content_type' => "$mimeType");
        $changeSetGuid = Utilities::getGuid();
        $changeSetId   = sprintf('changeset_%s', $changeSetGuid);
        $contentType2  = array('content_type' => "$mimeType; boundary=$changeSetId");
        $options       = array(
            'encoding'     => 'binary',
            'content_type' => Resources::HTTP_TYPE
        );

        $eof = "\r\n";

        $result            = array();
        $result['body']    = Resources::EMPTY_STRING;
        $result['headers'] = array();

        $batchBody         =& $result['body'];
        $batchHeaders      =& $result['headers'];

        $batchHeaders['Content-Type'] = $mimeType . "; $eof boundary=\"$batchId\"";

        $batchBody .= "--" . $batchId . $eof;
        $batchBody .= "Content-Type: $mimeType; boundary=\"$changeSetId\"" . $eof;

        $batchBody .= $eof;
        for ($i = 0; $i < count($bodyPartContents); $i++) {
            $batchBody .= "--" . $changeSetId . $eof;

            $batchBody .= "Content-Transfer-Encoding: binary" . $eof;
            $batchBody .= "Content-Type: " . Resources::HTTP_TYPE . $eof;

            $batchBody .= $eof . $bodyPartContents[$i] . $eof;
        }
        $batchBody .= "--" . $changeSetId . "--" . $eof;
        $batchBody .= $eof;
        $batchBody .= "--" . $batchId . "--" . $eof;

        return $result;
    }
public function encodeMimeMultipart ( array $ bodyPartContents ) { $ count = count ( $ bodyPartContents ) ; $ mimeType = Resources :: MULTIPART_MIXED_TYPE ; $ batchGuid = Utilities :: getGuid ( ) ; $ batchId = sprintf ( 'batch_%s' , $ batchGuid ) ; $ contentType1 = array ( 'content_type' => "$mimeType" ) ; $ changeSetGuid = Utilities :: getGuid ( ) ; $ changeSetId = sprintf ( 'changeset_%s' , $ changeSetGuid ) ; $ contentType2 = array ( 'content_type' => "$mimeType; boundary=$changeSetId" ) ; $ options = array ( 'encoding' => 'binary' , 'content_type' => Resources :: HTTP_TYPE ) ; $ eof = "\r\n" ; $ result = array ( ) ; $ result [ 'body' ] = Resources :: EMPTY_STRING ; $ result [ 'headers' ] = array ( ) ; $ batchBody = & $ result [ 'body' ] ; $ batchHeaders = & $ result [ 'headers' ] ; $ batchHeaders [ 'Content-Type' ] = $ mimeType . "; $eof boundary=\"$batchId\"" ; $ batchBody .= "--" . $ batchId . $ eof ; $ batchBody .= "Content-Type: $mimeType; boundary=\"$changeSetId\"" . $ eof ; $ batchBody .= $ eof ; for ( $ i = 0 ; $ i < count ( $ bodyPartContents ) ; $ i ++ ) { $ batchBody .= "--" . $ changeSetId . $ eof ; $ batchBody .= "Content-Transfer-Encoding: binary" . $ eof ; $ batchBody .= "Content-Type: " . Resources :: HTTP_TYPE . $ eof ; $ batchBody .= $ eof . $ bodyPartContents [ $ i ] . $ eof ; } $ batchBody .= "--" . $ changeSetId . "--" . $ eof ; $ batchBody .= $ eof ; $ batchBody .= "--" . $ batchId . "--" . $ eof ; return $ result ; }
Given array of MIME parts in raw string, this function converts them into MIME
representation.

@param array $bodyPartContents The MIME body parts.

@return array Returns array with two elements 'headers' and 'body' which
represents the MIME message.
Given array of MIME parts in raw string this function converts them into MIME representation .