欢迎光临
我们一直在努力

自动生成SERVER CONTROLS在程序里的应用-.NET教程,面向对象编程

建站超值云服务器,限时71元/月

        private string listfolder(easymailimap4lib.easymailimap4 imap4,string strfolder,int perpage)
        {
            tablerow r;
            tablecell c;
            int x,pages,pgnum,start,end;
            string str1;

            x = imap4.selectmailbox(strfolder);
            if(x != 0)
            {
                imap4.createmailbox(strfolder);
                return "(created!)";
            }
            else
            {   

                r = new tablerow();
                c = new tablecell();            
                str1 = "当前邮箱 "+strfolder+" ";
                str1 = str1+"共有邮件 "+imap4.messagecount+" 封";
                folder_info.text = str1;

                if(imap4.messagecount==0)
                {
                  return "no message";
                }

                if((imap4.messagecount%perpage) ==0 )
                {
                    pages=imap4.messagecount/perpage;
                }
                else
                {
                    pages=(int)imap4.messagecount/perpage+1;
                }

                pgnum=1;
                try
                {
                    pgnum=convert.toint32(request.querystring["pg"].tostring());     
                }
                catch
                {
                    pgnum=1;
                }

                
                if(pgnum>1)
                {
                    end=pgnum*perpage;
                    start=end-perpage+1;
                }
                else
                {
                    end=perpage;
                    start=1;
                }

                x = imap4.downloadenvelopes(start, end, 0);
                
                if(x != 0)
                {
                    return "(error:"+x+")";
                }

                r = new tablerow();

                c = new tablecell();
                c.controls.add(new literalcontrol(""));
                c.width=15;
                r.cells.add(c);

                c = new tablecell();
                c.controls.add(new literalcontrol(""));
                c.width=15;
                r.cells.add(c);

                c = new tablecell();
                c.controls.add(new literalcontrol("发件人"));
                c.attributes.add("nowrap","true");                
                c.attributes.add("align","center");
                c.width=80;
                r.cells.add(c);
                
                c = new tablecell();
                c.controls.add(new literalcontrol("主题"));
                c.attributes.add("align","center");
                r.cells.add(c);
                
                c = new tablecell();
                c.controls.add(new literalcontrol("日期"));
                c.attributes.add("align","center");
                c.width=120;
                r.cells.add(c);
                
                c = new tablecell();
                c.controls.add(new literalcontrol("大小"));
                c.width=40;
                c.attributes.add("align","center");
                r.cells.add(c);
                
                c = new tablecell();
                c.controls.add(new literalcontrol("附"));
                c.attributes.add("align","center");
                c.width=10;
                r.cells.add(c);
                r.backcolor=system.drawing.color.fromname("#6699cc");
                r.forecolor=system.drawing.color.whitesmoke;
                listtable.rows.add(r);

                easymailimap4lib.iemimap4envelopes penvelopes;
                penvelopes= (easymailimap4lib.iemimap4envelopes) imap4.envelopes ;

                easymailimap4lib.iemimap4message pmessage;
                easymailimap4lib.iemimap4attachments  pattachments;
                ienumerator e = penvelopes.getenumerator();

                checkbox o;
                foreach(easymailimap4lib.iemimap4envelope penvelope in penvelopes)
                {
                    imap4.downloadmessage(penvelope.imapid,1);
                    pmessage = (easymailimap4lib.iemimap4message) imap4.message;

                    r = new tablerow();

                    c = new tablecell();            
                    o = new checkbox();
                    o.id=penvelope.imapid.tostring();
                    //mailboxesform.controls.add(o);
    
                    //str1="<input type=\"checkbox\" name=\"chk" + penvelope.imapid.tostring() + "\" class=\"in1\" style=\"width:15px;height:15px\">";
                    //c.controls.add(new literalcontrol(""));
                    c.controls.add(o);
                    c.attributes.add("align","center");
                    r.cells.add(c);

                    c = new tablecell();                
                    if (pmessage.priority.tostring()=="1")
                    {
                        str1="<font color=red style=\"width:15px;height:15px\">!</font>";
                    }
                    else
                    {
                        str1=" &nbsp";
                    }
                    c.controls.add(new literalcontrol(str1));
                    c.attributes.add("align","right");
                    r.cells.add(c);

                    c = new tablecell();                    
                    c.controls.add(new literalcontrol(penvelope.from));
                    c.attributes.add("nowrap","true");                
                    c.width=80;
                    r.cells.add(c);
                    
                    c = new tablecell();                    
                    str1 = "<a href=\"viewdraft.aspx?folder="+strfolder+"&imapid=" + penvelope.imapid.tostring() + "\">"+penvelope.subject+"</a>";
                    c.controls.add(new literalcontrol(str1));
                    r.cells.add(c);
                    

                    c = new tablecell();                    
                    c.controls.add(new literalcontrol(penvelope.date.substring(0,20)));
                    r.cells.add(c);
                    
                    c = new tablecell();            
                    if (penvelope.size/1000<1)
                    {
                        c.controls.add(new literalcontrol(penvelope.size.tostring()+"b"));
                    }
                    else
                    {
                        if (penvelope.size/1000000<1)
                        {
                            c.controls.add(new literalcontrol((penvelope.size/1000).tostring()+"k"));
                        }
                        else
                        {
                            c.controls.add(new literalcontrol((penvelope.size/1000).tostring()+"m"));
                        }
                    }
                    c.attributes.add("align","right");
                    r.cells.add(c);
                    
                    c = new tablecell();        
                    pattachments = (easymailimap4lib.iemimap4attachments) pmessage.attachments;
                    if(pattachments.count>0)
                    {
                        c.controls.add(new literalcontrol("有"));
                    }
                    else
                    {
                        c.controls.add(new literalcontrol("无"));
                    }
                    c.attributes.add("align","center");
                    r.cells.add(c);
                    
                    listtable.rows.add(r);

                }

                r = new tablerow();
                c = new tablecell();            
                str1 = "<a style=\"text-decoration: none;\" href=\"drafts.aspx?pg=1\"> << </a> ";
                if(pgnum==1)
                {
                    str1 = str1+"< ";
                }
                else
                {
                    str1 = str1+"<a style=\"text-decoration: none;\" href=\"drafts.aspx?pg=" + (pgnum-1) + "\"> < </a> ";
                }
                if(pgnum==pages)
                {
                    str1 = str1+"> ";
                }
                else
                {
                    str1 = str1+"<a style=\"text-decoration: none;\" href=\"drafts.aspx?pg=" + (pgnum+1) + "\"> > </a> ";
                }
                str1 = str1+"<a style=\"text-decoration: none;\" href=\"drafts.aspx?pg=" + pages+ "\"> >> </a>  ";
                c.controls.add(new literalcontrol(str1));
                c.attributes.add("align","right");
                c.columnspan=7;
                r.cells.add(c);
                listtable.rows.add(r);
                
                return "ok";
            }
        }

这段生成乐一个checkbox控制对象加入的列邮件的table里面去
这样就通过这些checkbox来选择特定邮件来进行删除,修改朝左

o = new checkbox();    
o.id=penvelope.imapid.tostring();
c.controls.add(o);

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 自动生成SERVER CONTROLS在程序里的应用-.NET教程,面向对象编程
分享到: 更多 (0)