There's a disconnect between what you're asking and what you want. Specifically, RFC 822 doesn't recognize attachments. As far as RFC 822 is concerned, an email is just a set of headers followed by the message body. There are several other RFC's you'll want to look at to see exactly how attachments are stored in email (989, 1421, 2822, and probably some others).
But the upshot is that you shouldn't have to worry about it. Simply take the entire raw message and put it in a CDATA section within the apps:rfc822Msg
element. A sample:
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:batch="http://schemas.google.com/gdata/batch"
xmlns:gd="http://schemas.google.com/g/2005">
<entry>
<category term="http://schemas.google.com/apps/2006#mailItem" scheme="http://schemas.google.com/g/2005#kind" />
<apps:rfc822Msg xmlns:apps="http://schemas.google.com/apps/2006">
<![CDATA[MIME-Version: 1.0
Received: by 10.143.9.6 with HTTP; Fri, 26 Feb 2010 08:11:48 -0800 (PST)
Date: Fri, 26 Feb 2010 10:11:48 -0600
Delivered-To: [email protected]
Message-ID: <[email protected]>
Subject: Example
From: Joe Schmo <[email protected]>
To: [email protected]
Content-Type: multipart/mixed; boundary=000e0cd2dd1216bdff04808328cb
--000e0cd2dd1216bdff04808328cb
Content-Type: multipart/alternative; boundary=000e0cd2dd1216bdf404808328c9
--000e0cd2dd1216bdf404808328c9
Content-Type: text/plain; charset=ISO-8859-1
This is the message body text.
--000e0cd2dd1216bdf404808328c9
Content-Type: text/html; charset=ISO-8859-1
This is the message body text.
--000e0cd2dd1216bdf404808328c9--
--000e0cd2dd1216bdff04808328cb
Content-Type: text/plain; charset=US-ASCII; name="test.txt"
Content-Disposition: attachment; filename="test.txt"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_g656ktq20
VGhpcyBpcyBhIHRlc3Q=
--000e0cd2dd1216bdff04808328cb--]]>
</apps:rfc822Msg>
<apps:mailItemProperty value="IS_STARRED"
xmlns:apps="http://schemas.google.com/apps/2006" />
<apps:mailItemProperty value="IS_UNREAD"
xmlns:apps="http://schemas.google.com/apps/2006" />
<apps:label labelName="Event Invitations"
xmlns:apps="http://schemas.google.com/apps/2006" />
<apps:label labelName="Friends"
xmlns:apps="http://schemas.google.com/apps/2006" />
<batch:id>0</batch:id>
</entry>
</feed>