如何在C#windows窗体应用程序s22.imap中获取数据网格视图中的所有邮件 [英] How can I get all mail in data grid view in C# windows form application s22.imap

查看:414
本文介绍了如何在C#windows窗体应用程序s22.imap中获取数据网格视图中的所有邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好每个人正在研究一个项目现在我有问题。即时通讯使用s22.imap库我现在可以先打开看不见的邮件并在文本框中显示

i想要获得前10个或所有看不见的电子邮件数据网格视图是否有可能请帮助我该怎么做?



我尝试了什么:



hello every one im working on a project now i have issue. im using s22.imap library now i can gent first unseen mail and show in text box
i want to get first 10 or all unseen email in data grid view is it possible please help how can i do this ?

What I have tried:

using (ImapClient client = new ImapClient(hostname, 993, username, password, AuthMethod.Login, true))
            {

                IEnumerable<uint> uids = client.Search(SearchCondition.Unseen());

                // Fetch the mail headers of the first message and print it's subject line.
                if (uids.Count() > 0)
                {
                    MailMessage msg = client.GetMessage(uids.First(), FetchOptions.TextOnly);

                    s= ("Subject: " + msg.Subject);
                    textBox1.Text = s;
                    d=("From:" + msg.From);
                    textBox2.Text = d;
                    
                    b = ("Body: " + msg.Body);
                    textBox3.Text = b;
                    
                }</uint>

推荐答案

使用

Use
var firstTen = client.GetMessages(uids.Take(10), FetchOptions.TextOnly)
foreach(MailMessage msg in firstTen)
{
    // ... your code here
}



(未经测试)


这篇关于如何在C#windows窗体应用程序s22.imap中获取数据网格视图中的所有邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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