我用的是WebControls.Table +string[]
:
private void  RecMailIndex()
{
jmail.Message Msg=new jmail.Message();
jmail.POP3 jpop=new jmail.POP3();
try
{
jpop.Connect(this.user.Text,this.passwd.Text,this.host.Text,110);

//
this.show_head();//this table1 header
//     strcontent=new string[jpop.Count]; for(int n=1;n<=jpop.Count;n++)
{
Msg = jpop.Messages[n]; this.show_row(n,Msg.FromName,Msg.Subject,Msg.Date.ToString());
this.strcontent[n-1]=Msg.Body;
}
//
this.Session["strContent"]=null;
this.Session["strContent"]=this.strcontent;
// jpop.Disconnect();
}
catch(Exception ex)
{
this.Response.Write("there some errors: as"+ex.Message.ToString());
this.Response.End();
} }
#region show_head()
private void show_head()
{
TableRow tr;
TableCell tc;
tr=new TableRow();
tr.BackColor = Color.LightBlue;
this.Table1.Rows.Add(tr);
//
tc=new TableCell();
tc.HorizontalAlign =HorizontalAlign.Center;
tc.Wrap=false;
tc.Text="选中";
tr.Cells.Add(tc);
//
//
tc=new TableCell();
tc.HorizontalAlign =HorizontalAlign.Center;
tc.Wrap=false;
tc.Text="主题";
tr.Cells.Add(tc);
//
tc=new TableCell();
tc.Text="发件人";
tc.Wrap=false;
tr.Cells.Add(tc);
//
tc=new TableCell();
tc.Text="接收时间";
tc.Wrap=false;
tr.Cells.Add(tc);
}
#endregion
//
#region show_row() 带有HyperLink
private void show_row(int i,string strFromName,string strSubject,string strRecTime)
{
TableRow tr;
TableCell tc;
tr=new TableRow();
tr.BackColor = Color.FromArgb(236,245,251);
this.Table1.Rows.Add(tr);
//
tc=new TableCell();
tc.Width =8;
System.Web.UI.WebControls.CheckBox chbx =new System.Web.UI.WebControls.CheckBox();
//将编号帮定到chbx的id上!因为id唯一!!
chbx.ID="chbx"+i.ToString();
tc.Controls.Add(chbx);
tr.Cells.Add(tc);
//
/*
tc=new TableCell();
System.Web.UI.WebControls.LinkButton lbtn =new System.Web.UI.WebControls.LinkButton();
lbtn.Click += new System.EventHandler(this.LinkButtonClick);
lbtn.Text=strSubject;
//将编号帮定到chbx的id上!因为id唯一!!
lbtn.ID="chbx"+i.ToString();
tc.Controls.Add(lbtn);
tr.Cells.Add(tc);
*/
tc=new TableCell();
System.Web.UI.WebControls.HyperLink hlk =new System.Web.UI.WebControls.HyperLink();
//以下为超连接
hlk.NavigateUrl="ShowMail.aspx?"+i.ToString()+"&FromName="+strFromName+"&Subject="+strSubject+"&RecTime="+strRecTime;
hlk.Text=strSubject;
//将编号帮定到chbx的id上!因为id唯一!!
hlk.ID="hlk"+i.ToString();
tc.Controls.Add(hlk);
tr.Cells.Add(tc);
//
tc=new TableCell();
tc.Text=strFromName;
tc.Wrap=false;
tr.Cells.Add(tc);
//
tc=new TableCell();
tc.Text=strRecTime;
tc.Wrap=false;
tr.Cells.Add(tc);
}
#endregion
//