使用c#在gmail id中下载附件 [英] download attachments in gmail id using c#

查看:123
本文介绍了使用c#在gmail id中下载附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用c#创建一个Windows窗体应用程序,我的任务是下载一个特定发件人发送的附件(比如abc),每天。我谷歌了近2天,但是,一切都是徒劳的。我试过用Pop3,它只显示未读的邮件,以某种随机顺序,我不明白为什么。 Imap也显示了很多错误,我只需要下载一个附件,每天从我的客户发送的邮件(abc),请帮助。

I want to create a windows form application using c#,my task is to download the attachment sent by one particular sender(say abc),daily.I google'd nearly for 2days,but,all in vain.I tried using Pop3,it shows only the unread mails,that to in some random order,i do not understand why. Imap is also showing so many errors,all i need to do is download ONLY ONE attachment,daily from a mail sent by my customer(abc),pls help.

推荐答案

没有下载附件这样的东西。如果某些邮件内容是某些Web链接,那么您可能需要下载某些内容,但它不会成为邮件的一部分。



实际上,这个词依恋极具误导性。实际上没有任何东西附加到邮件中。实际上,所有邮件内容只是一个纯文本块(可能是Unicode UTF或其他一些编码),没有别的。一切都嵌入在那一块中。看起来像附件的实际上是邮件部分,由内容类型的顶级标题中定义的文本分隔符分隔。这些部分具有各自的标题组,并且每个部分的内容类型(以及处置)可以不同。如果该部分的内容是二进制,则它仍然是纯文本,内容编码为base64:

http://en.wikipedia.org/wiki/Base64 [ ^ ]。



您需要将其全部解析为按钮。所有这些的格式由整套标准定义,因此您需要进行大量阅读: http://en.wikipedia.org/wiki/E-mail#Message_format [ ^ ]。



相反,您可以使用一些可用的解析器。请特别阅读本教程: http://www.emailarchitect.net/eagetmail/kb/ csharp.aspx?cat = 18 [ ^ ]。



看看这个开源解析器: http ://mimeparser.codeplex.com/ [ ^ ]。< br $>


-SA
There is no such thing as "downloading attachments". If some of the mail content is some Web links, then you may have something to download, but it would not be a part of a message.

Actually, the term "attachment" is highly misleading. Nothing is actually "attached" to the mail. Actually, all the mail content is just one solid block of plain text (possibly in one of Unicode UTFs or some other "encoding"), nothing else. Everything is embedded in that single block. What looks like "attachment" is actually a mail part, separated by text separators defined in the top-level header of content type. Those "parts" have their separate groups of headers, and content types (and also "dispositions") can be different for each part. If content of the part is "binary", it is still plain text, with content encoded as base64:
http://en.wikipedia.org/wiki/Base64[^].

You need to parse it all top to button. The format of all this is defined by the whole set of standards, so you would need to do a good amount of reading: http://en.wikipedia.org/wiki/E-mail#Message_format[^].

Instead, you can use some available parser. In particular, please read this tutorial: http://www.emailarchitect.net/eagetmail/kb/csharp.aspx?cat=18[^].

Look at this open-source parser: http://mimeparser.codeplex.com/[^].

—SA


这篇关于使用c#在gmail id中下载附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆