diff --git a/addressbook/e-book-backend-exchange.c b/addressbook/e-book-backend-exchange.c
index 1f72e6d..7bc0488 100644
--- a/addressbook/e-book-backend-exchange.c
+++ b/addressbook/e-book-backend-exchange.c
@@ -542,16 +542,16 @@ e_contact_from_props (EBookBackendExchange *be, E2kResult *result)
 
 		if (content) {
 			EContactPhoto photo;
-			CamelStreamMem *stream_mem;
+			GByteArray *mem_bytes;
 
-			stream = camel_stream_mem_new ();
-			stream_mem = (CamelStreamMem *)stream;
+			mem_bytes = g_byte_array_new ();
+			stream = camel_stream_mem_new_with_byte_array (mem_bytes);
 			camel_data_wrapper_decode_to_stream (content, stream);
 
 			photo.type = E_CONTACT_PHOTO_TYPE_INLINED;
 			photo.data.inlined.mime_type = NULL;
-			photo.data.inlined.data = stream_mem->buffer->data;
-			photo.data.inlined.length = stream_mem->buffer->len;
+			photo.data.inlined.data = mem_bytes->data;
+			photo.data.inlined.length = mem_bytes->len;
 			e_contact_set (contact, E_CONTACT_PHOTO, &photo);
 
 			camel_object_unref (stream);
diff --git a/calendar/e-cal-backend-exchange.c b/calendar/e-cal-backend-exchange.c
index f86783a..6701af5 100644
--- a/calendar/e-cal-backend-exchange.c
+++ b/calendar/e-cal-backend-exchange.c
@@ -1727,18 +1727,17 @@ get_attachment (ECalBackendExchange *cbex, const gchar *uid,
 			part = camel_multipart_get_part (multipart, i);
 			filename = camel_mime_part_get_filename (part);
 			if (filename) {
-				CamelStreamMem *stream_mem;
+				GByteArray *mem_bytes = g_byte_array_new ();
 
 				content = camel_medium_get_content_object (CAMEL_MEDIUM (part));
 
-				stream = camel_stream_mem_new ();
-				stream_mem = (CamelStreamMem *)stream;
+				stream = camel_stream_mem_new_with_byte_array (mem_bytes);
 
 				camel_data_wrapper_decode_to_stream (content, stream);
-				attach_data = g_memdup (stream_mem->buffer->data, stream_mem->buffer->len);
+				attach_data = g_memdup (mem_bytes->data, mem_bytes->len);
 				attach_file = g_strdup_printf ("%s/%s-%s", cbex->priv->local_attachment_store, uid, filename);
 				// Attach
-				attach_file_url = save_attach_file (attach_file, (gchar *) attach_data, stream_mem->buffer->len);
+				attach_file_url = save_attach_file (attach_file, (gchar *) attach_data, mem_bytes->len);
 				g_free (attach_data);
 				g_free (attach_file);
 				d(printf ("attach file name : %s\n", attach_file_url));
@@ -1935,13 +1934,14 @@ gchar *
 build_msg ( ECalBackendExchange *cbex, ECalComponent *comp, const gchar *subject, gchar **boundary)
 {
 	CamelMimeMessage *msg;
-	CamelStreamMem *content;
+	CamelStream *mem_content;
 	CamelMimePart *mime_part;
 	CamelDataWrapper *dw, *wrapper;
 	CamelMultipart *multipart;
 	CamelInternetAddress *from;
 	CamelStream *stream;
 	CamelContentType *type;
+	GByteArray *mem_bytes;
 	const gchar *uid;
 	gchar *buffer = NULL, *cid;
 	gchar *from_name = NULL, *from_email = NULL;
@@ -2050,13 +2050,13 @@ build_msg ( ECalBackendExchange *cbex, ECalComponent *comp, const gchar *subject
 	camel_medium_set_content_object (CAMEL_MEDIUM (msg), CAMEL_DATA_WRAPPER (multipart));
 	camel_object_unref (multipart);
 
-	content = (CamelStreamMem *)camel_stream_mem_new();
+	mem_bytes = g_byte_array_new ();
+	mem_content = camel_stream_mem_new_with_byte_array (mem_bytes);
 	dw = camel_medium_get_content_object (CAMEL_MEDIUM (msg));
-	camel_data_wrapper_decode_to_stream(dw, (CamelStream *)content);
-	buffer = g_memdup (content->buffer->data, content->buffer->len);
-	buffer[content->buffer->len] = '\0';
+	camel_data_wrapper_decode_to_stream (dw, mem_content);
+	buffer = g_strndup ((const gchar *)mem_bytes->data, mem_bytes->len);
 	d(printf ("|| Buffer: \n%s\n", buffer));
-	camel_object_unref (content);
+	camel_object_unref (mem_content);
 	camel_object_unref (msg);
 
 	return buffer;
diff --git a/camel/camel-exchange-folder.c b/camel/camel-exchange-folder.c
index 5d1db84..56403a7 100644
--- a/camel/camel-exchange-folder.c
+++ b/camel/camel-exchange-folder.c
@@ -246,7 +246,7 @@ append_message (CamelFolder *folder, CamelMimeMessage *message,
 {
 	CamelStream *stream_mem;
 	CamelExchangeStore *store = CAMEL_EXCHANGE_STORE (folder->parent_store);
-
+	GByteArray *mem_bytes;
 	gchar *old_subject = NULL;
 	GString *new_subject;
 	gint i, len;
@@ -278,12 +278,13 @@ append_message (CamelFolder *folder, CamelMimeMessage *message,
 		camel_exchange_journal_append ((CamelExchangeJournal *) ((CamelExchangeFolder *)folder)->journal, message, info, appended_uid, ex);
 		return;
 	}
-	stream_mem = camel_stream_mem_new ();
+	mem_bytes = g_byte_array_new ();
+	stream_mem = camel_stream_mem_new_with_byte_array (mem_bytes);
 	camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message),
 					    stream_mem);
 	camel_stream_flush (stream_mem);
 
-	append_message_data (folder, CAMEL_STREAM_MEM (stream_mem)->buffer,
+	append_message_data (folder, mem_bytes,
 			     camel_mime_message_get_subject (message),
 			     info, appended_uid, ex);
 
