2

您好,我正在开发 .NET 1.1 中的一个项目,我需要从收到的电子邮件中提取(并将其保存在某处)嵌入图像。

有人可以告诉我从哪里开始吗?

谢谢你

4

1 回答 1

2

从 POP 服务器下载的电子邮件将是文本格式,您必须解析整个电子邮件,并找到所有属性设置为的<img />标签srccid:*

例如

<img src='cid:006901c6d391$dee64770$6c822ecf@Z2LC74Q' />

包含嵌入图像的电子邮件格式如下 -

From: foo1atbar.net 
To: foo2atbar.net 
Subject: A simple example 
Mime-Version: 1.0 
Content-Type: multipart/related; boundary="boundary-example"; type="text/html" 

--boundary-example 
Content-Type: text/html; charset="US-ASCII" 

... text of the HTML document, which might contain a URI 
referencing a resource in another body part, for example 
through a statement such as: 
<IMG SRC="cid:foo4atfoo1atbar.net" ALT="IETF logo"> 
...snip...
Content-Location: CID:somethingatelse ;this header is disregarded 
Content-ID: <006901c6d391$dee64770$6c822ecf@Z2LC74Q>
Content-Type: IMAGE/GIF 
Content-Transfer-Encoding: BASE64 

R0lGODlhGAGgAPEAAP/////ZRaCgoAAAACH+PUNv 
cHlyaWdodCAoQykgMTk5LiBVbmF1dGhvcml6ZWQgZHV 
wbGljYXRpb24gcHJvaGliaXRlZC4A etc... 

...snip...

如果您查看页脚,它包含图像的 BASE64 编码版本。您可以提取 BASE64 字符串,根据电子邮件字符集将其转换为字节,然后将其保存到文件中(您可以根据 Content-Type 获取文件扩展名)。达达,搞定!

希望你对如何做到这一点有所了解!

编辑

我在这里也发现了一个类似的问题。他正在使用 CDO(协作数据对象)。

于 2009-08-11T12:29:43.077 回答