我正在寻找一个c#代码,只从收件箱中检索邮件及其附件。 [英] I am looking for a c# code to retreive mails and its attachment from only inbox.

查看:71
本文介绍了我正在寻找一个c#代码,只从收件箱中检索邮件及其附件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在寻找一个只从收件箱中检索邮件和附件的代码,我在google上做了很多搜索,最后我发现了一些代码在哪里,感谢作者,但它检索了所有文件夹中的所有邮件(收件箱,发送,垃圾箱) ..),任何人都可以帮到这里



代码如下,任何人都可以过滤它。





  public 列表<电子邮件> FetchEmailList( int  start, int  count)
{
List< Email> email = new 列表<电子邮件>(计数);
for int i = start; i < (开始+计数); i ++)
{
电子邮件= FetchEmail(i);
if (email!= null
emails.Add(email);
}
返回电子邮件;
}





  public 电子邮件FetchEmail( int  emailId)
{
if (IsResponseOk(SendCommand( TOP + emailId + < span class =code-string> 0)))
return new Email(ReadLines());
else
return null < /跨度>;
}









提前致谢。

解决方案

有时候尝试获得一些关于你愿意做什么的背景是一个好主意。要从服务器下载电子邮件,请使用所谓的电子邮件协议。两种最常用的是POP3和IMAP。考虑到这一点,您可以去搜索pop3 client c# [< a href =https://www.google.es/#q=pop3+client+c%23target =_ blanktitle =新窗口> ^ ]



OpenPop.NET [ ^ ]库实现了协议以及MIME解析器。



你会发现一些关于IMAP(客户端):简单的IMAP客户端 [ ^ ]和这里: C#中的IMAP和POP3客户端 [ ^ ]。



那些项目你将获得它所需的背景部分。


你应该在文章末尾的论坛中发帖提问,以便作者看到。


 hi 
感谢您的建议
i我能在这里找到我的解决方案http://www.limilabs.com/blog /下载电子邮件,从Gmail邮箱#注释-572692\"


Hi I am looking for a code to retrieve mails and attachments from only inbox,i have done a lot of search on google, at last i found some code here , thanks to the author,but it retrieves all the mails from all the folders(Inbox,sent,trash..), can any one help here

the code follows here, can any one filter it.


public List<Email> FetchEmailList(int start, int count)
        {
            List<Email> emails = new List<Email>(count);
            for (int i = start; i < (start + count); i++)
            {
                Email email = FetchEmail(i);
                if (email != null)
                    emails.Add(email);
            }
            return emails;
        }



public Email FetchEmail(int emailId)
        {
            if (IsResponseOk(SendCommand("TOP " + emailId + " 0")))
                return new Email(ReadLines());
            else
                return null;
        }





Thanks in advance.

解决方案

Some times it's a good idea trying to get some background about what you're willing to do. For downloading e-mails from the server you use what is called e-mail protocol. Two of the most commonly used ones are POP3 and IMAP. With this in mind you can go and search for something like "pop3 client c#"[^]

The OpenPop.NET[^] library implements the protocol and also the MIME parser.

You will find something about IMAP (client) here: Simple IMAP CLIENT[^] and here: IMAP and POP3 Clients in C#[^].

Looking at those projects you'll get part of the background you need for it.


You should post your question in the forum at the end of the article so the author can see it.


hi
Thanks all  for your suggestion
i am able to find my solution here "http://www.limilabs.com/blog/download-emails-from-gmail#comment-572692"


这篇关于我正在寻找一个c#代码,只从收件箱中检索邮件及其附件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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