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);
            }
I think , you are doing correct only small point
Put a null check for bundle and email object. 
  for (i = 0; i < bundle.MessageCount - 0; i++)  m, why are you substracting 0 from bundle.MessageCount
your code is simple and its doing what it is intended to do so why change at this time.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论