开发者

How to add attachment in RFC822 format MAIL using Google API?

开发者 https://www.devze.com 2022-12-21 14:28 出处:网络
I am trying to add attachment in RFC822 format MAIL using Google API (c#). Referring to this link http://code.google.com/apis/apps/email_migration/developers_guide_dotnet.html

I am trying to add attachment in RFC822 format MAIL using Google API (c#).

Referring to this link

http://code.google.com/apis/apps/email_migration/developers_guide_dotnet.html

How should i start?

Can anyone give me sample mail value?

Is there any study material or documen开发者_高级运维tation available on net.To understand Google Apps Email Migration API.


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: joschmo@gmail.com
Message-ID: <4a3140f1002260811v6c539c42rda718def8bb7e168@mail.gmail.com>
Subject: Example
From: Joe Schmo <joschmo@gmail.com>
To: joschmo@gmail.com
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>


Since you're migrating messages I assume you have access to the original raw message, which should have everything in place already (all attachments correctly encoded for email transmission). If that's the case you just need to follow the example in Migrating Email Messages where rfcTextOfMessage is the full raw message you want to migrate.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号