获取电子邮件正文c#.net

时间:2010-09-08 20:36:29

标签: c# email pop3 chilkat

我使用chilkat组件Available Here在列表框中显示电子邮件的主题和发件人。有一种方法,当用户点击列表框中邮件的主题时,正文将显示在下面的texbox。

提前致谢

到目前为止

代码

 // Set the GMail account POP3 properties.
        mailman.MailHost = "pop.gmail.com";
        mailman.PopUsername = "**********";
        mailman.PopPassword = "**********";
        mailman.PopSsl = true;
        mailman.MailPort = 995;

        Chilkat.EmailBundle bundle;
        // Read mail headers and one line of the body.
        // To get the full emails, call CopyMail instead (no arguments)
        bundle = mailman.GetEmail(1);

        if (bundle == null)
        {
            MessageBox.Show(mailman.LastErrorText);
            return;
        }

        int i;
        Chilkat.Email email;
        for (i = 0; i <= bundle.MessageCount - 1; i++)
        {
            email = bundle.GetEmail(i);

            // Display the From email address and the subject.
             listBox1.Items.Add( email.From + "\r\n");
             listBox1.Refresh();
             listBox2.Items.Add( email.Subject + "\r\n" + "\r\n");
             listBox2.Refresh();
             textBox1.Text += email.Body + "\r\n" + "\r\n";


        }


    }
}

0 个答案:

没有答案