本文介绍了我想用pop3Client阅读Gmail收件箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用此代码检索邮件但是,它会随机发送所有邮件,包括已发送的邮件和收件箱

I try this code to retrieve mail but, its give all mail including sent Item and inbox randomly

Pop3Client pop3Client;
        if (Session["Pop3Client"] == null)
        {
            pop3Client = new Pop3Client();
            pop3Client.Connect(txtMailServer.Text, int.Parse(txtPort.Text), true);
            pop3Client.Authenticate(txtUserName.Text, txtPassword.Text);
            Session["Pop3Client"] = pop3Client;
        }
        else
        {
            pop3Client = (Pop3Client)Session["Pop3Client"];
        }
        int count = pop3Client.GetMessageCount();

        List<string> Uids = pop3Client.GetMessageUids();

        DataTable dtMessages = new DataTable();
        dtMessages.Columns.Add("MessageNumber");
        dtMessages.Columns.Add("From");
        dtMessages.Columns.Add("Subject");
        dtMessages.Columns.Add("DateSent");
        int counter = 0;
        for (int i = count; i >= 1; i--)
        {
            Message message = pop3Client.GetMessage(i);
            dtMessages.Rows.Add();
            dtMessages.Rows[dtMessages.Rows.Count - 1]["MessageNumber"] = i;
            dtMessages.Rows[dtMessages.Rows.Count - 1]["Subject"] = message.Headers.Subject;
            dtMessages.Rows[dtMessages.Rows.Count - 1]["DateSent"] = message.Headers.DateSent;
            counter++;
            if (counter > 10)
            {
                break;
            }
        }
        
        gvEmails.DataSource = dtMessages;
        gvEmails.DataBind();  



我想只读取收件箱

请帮助

提前谢谢..


I want to read only inbox
please help
Thanks in advance..

推荐答案


这篇关于我想用pop3Client阅读Gmail收件箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 06:44