显示电子邮件的更好方法 c# winforms
你好,我有以下代码,它可以让我在列表视图控件上显示收件箱中的电子邮件,并在 rtb 中显示腐蚀正文我的问题是有没有更好的方法来处理这些数据并显示它,而不是下面的方式我很新c# 如此详细的答案会很棒
ps 我使用 chilkat imap 组件来处理服务器端,如果有事情 提前致谢
Chilkat.MessageSet msgSet = imap.Search("ALL", true);
bundle = imap.FetchBundle(msgSet);
Chilkat.Email email;
int i;
for (i = 0; i < bundle.MessageCount - 0; i++)
{
email = bundle.GetEmail(i);
System.Windows.Forms.ListViewItem itmp = new System.Windows.Forms.ListViewItem(email.From);
System.Windows.Forms.ListViewItem.ListViewSubItem itms1 = new System.Windows.Forms.ListViewItem.ListViewSubItem(itmp, email.Subject);
System.Windows.Forms.ListViewItem.ListViewSubItem itms2 = new System.Windows.Forms.ListViewItem.ListViewSubItem(itmp, email.FromName);
itmp.SubItems.Add(itms1);
itmp.SubItems.Add(itms2);
listView1.Items.Add(itmp).Tag = i;
richTextBox1.Text = email.Body;
}
// Save the email to an XML file
bundle.SaveXml("email.xml");
更新代码
Chilkat.MessageSet msgSet = imap.Search("ALL", true);
bundle = imap.FetchBundle(msgSet);
Chilkat.Email email;
int i;
for (i = 0; i < bundle.MessageCount; i++)
{
email = bundle.GetEmail(i);
string[] row = new string[]{email.From,
email.Subject,email.FromName};
object[] rows = new object[] { row };
foreach (string[] rowArray in rows)
{
listView1.Rows.Add(rowArray);
}
hello i have the following code which lets me display the emails in my inbox on a list view control and display the corrospoding body in a rtb my question is there a better way to handle this data and display it than the way below im pretty new to c# so detailed answers would be great
p.s im using the chilkat imap component to handle the server side if things
Thanks In Advance
Chilkat.MessageSet msgSet = imap.Search("ALL", true);
bundle = imap.FetchBundle(msgSet);
Chilkat.Email email;
int i;
for (i = 0; i < bundle.MessageCount - 0; i++)
{
email = bundle.GetEmail(i);
System.Windows.Forms.ListViewItem itmp = new System.Windows.Forms.ListViewItem(email.From);
System.Windows.Forms.ListViewItem.ListViewSubItem itms1 = new System.Windows.Forms.ListViewItem.ListViewSubItem(itmp, email.Subject);
System.Windows.Forms.ListViewItem.ListViewSubItem itms2 = new System.Windows.Forms.ListViewItem.ListViewSubItem(itmp, email.FromName);
itmp.SubItems.Add(itms1);
itmp.SubItems.Add(itms2);
listView1.Items.Add(itmp).Tag = i;
richTextBox1.Text = email.Body;
}
// Save the email to an XML file
bundle.SaveXml("email.xml");
Updated Code
Chilkat.MessageSet msgSet = imap.Search("ALL", true);
bundle = imap.FetchBundle(msgSet);
Chilkat.Email email;
int i;
for (i = 0; i < bundle.MessageCount; i++)
{
email = bundle.GetEmail(i);
string[] row = new string[]{email.From,
email.Subject,email.FromName};
object[] rows = new object[] { row };
foreach (string[] rowArray in rows)
{
listView1.Rows.Add(rowArray);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为,您只做正确的一小点,
您的代码很简单,并且它正在执行其预期的操作,所以为什么要在此时进行更改。
I think , you are doing correct only small point
your code is simple and its doing what it is intended to do so why change at this time.