• Pradeep d
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies

Am implementing records with checkboxes, during pagination process, state of checkbox is not maintaing in front end :( back end its working well, pls help ma issue.

public void init() {        
         wrapperRecordList = new List<WrapperClass>();
         system.debug(setCon.getRecords());
         for (Contact cont : (List<Contact>)setCon.getRecords()) {  
          if(mapHoldingSelectedRecords != null && mapHoldingSelectedRecords.containsKey(cont.id)){
           wrapperRecordList.add(new WrapperClass(cont, false));
           
         }
          else{
          wrapperRecordList.add(new WrapperClass(cont, false));
         }
         }
          system.debug(wrapperRecordList.size()); 
          
         }
         public List<Contact> conlist =  new List<contact>();
         public string doql;
         /** Instantiate the StandardSetController from a query locater*/
         public ApexPages.StandardSetController setCon {
         get {
         if(setCon == null) {
         
            //string soql = 'select id, lastname, name, email, phone from contact Limit :QUERY_LIMIT';
            
             string soql = 'SELECT id,LastName,AssistantName,AssistantPhone,Birthdate,Department,Description,Email,Fax,';
              soql      += 'HomePhone,MailingAddress,MailingCity,MailingCountry,MailingPostalCode,MailingState,datefield__c,To_date__c,' ;
              soql      += 'MailingStreet,MobilePhone,Name,firstname,OtherAddress,OtherCity,OtherCountry,OtherPhone,OtherPostalCode,';
              soql      += 'OtherState,OtherStreet,Account.Name,LastModifiedDate,Phone,Title,Mail_Sent_Date__c,' ;
              soql      += '(SELECT Assistant_Name__c,Assistant_Phone__c,Birthdate__c,Contact__c,CreatedById,'
                        + 'CreatedDate,Department__c,Description__c,Email__c,Fax__c,First_Name__c,Home_Phone__c,Id,IsDeleted,Mailing_City__c,'
                        +'Mailing_Country__c,Mailing_State_Province__c,Mailing_Street__c,Mailing_Zip_Postal_Code__c,Mobile_Phone__c,Name,'
                        +'Other_City__c,Other_Country__c,Other_Phone__c,Other_State_Province__c,Other_Street__c,Other_Zip_Postal_Code__c,'
                        +'OwnerId,Phone__c,Title__c from Cons__r) From Contact  ';
               doql = soql;
                system.debug('doql : ' + doql);
              
            
           setCon = new ApexPages.StandardSetController(Database.getQueryLocator(soql + ' Limit : QUERY_LIMIT' ));
           system.debug(setCon);
        
         }
           //Search();
           return setCon;
         }
         set;
         }
        
         public void countpage(){
         contactPaginationController_utility cu = new contactPaginationController_utility();
             cu.fromDate = fromDate;  
             cu.toDate = toDate;
             cu.lastDate30 = lastDate30 ;
             cu.lastDate60 = lastDate60 ;
             cu.lastDate90 = lastDate90 ;
         
         cu.querybat = querybat;
          cu.countall();
         
         }
          public void Search(){
           
            
              fromDate = con.datefield__c;
              toDate = con.To_date__c;
              directsend = con.schedule_check__c;
              lastDate30 = System.today().addDays(-30);
              lastDate60 = System.today().addDays(-60);
              lastDate90 = System.today().addDays(-90);
              system.debug(doql);
              string whereConditions = 'where ';
              string resultQuery = '' ;
             
                  
              if(con.datefield__c !=null && con.To_date__c !=null){          
                  resultQuery  = doql + whereConditions + ' LastModifiedDate >= :fromDate AND LastModifiedDate <= :toDate' ;
                
              }
              if(Con.Last_Sent_Date__c !='--None--'){
                  resultQuery  =  getLastsentDate(Con.Last_Sent_Date__c ,resultQuery) ;
               //   conlist = database.query(resultQuery + ' Limit : QUERY_LIMIT');
                //  system.debug(conlist);
              }
              if(string.isNotBlank(SelectedOption) && string.isNotBlank(selectedOperatorOption) && string.isNotBlank(enteredText)){
                  resultQuery = getOperatorSelection(SelectedOption,selectedOperatorOption,resultQuery,enteredText) ;
              }  
               system.debug(resultQuery + ' Limit : QUERY_LIMIT');
               
               
                querybat= resultQuery;
                
                if(directsend== true){
                 
                     updatecheck b2 = new updatecheck();
         
             b2.fromDate = fromDate;  
             b2.toDate = toDate;
             b2.lastDate30 = lastDate30 ;
             b2.lastDate60 = lastDate60 ;
             b2.lastDate90 = lastDate90 ;
             b2.queryString = querybat;  
          
             Database.executeBatch(b2); 
            
              
                 }
                else{
                 
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(resultQuery + ' Limit : QUERY_LIMIT' ));
                   system.debug(setCon.getRecords());
      
                setCon.setPageSize(PAGE_SIZE);
                init();
              
                }
                  system.debug(setCon);
              
           
           }
            public Boolean hasNext {
         get {
           return setCon.getHasNext();
         }
         set;
         }
         
         /** indicates whether there are more records before the current page set.*/
         public Boolean hasPrevious {
         get {
           return setCon.getHasPrevious();
         }
         set;
         }
         
         /** returns the page number of the current page set*/
         public Integer pageNumber {
         get {
           return setCon.getPageNumber();
         }
         set;
         }
         
         /** return total number of pages for page set*/
         Public Integer getTotalPages(){
             Decimal totalSize = setCon.getResultSize();
             Decimal pageSize = setCon.getPageSize();
             Decimal pages = totalSize/pageSize;
             return (Integer)pages.round(System.RoundingMode.CEILING);
         }
         
         /** returns the first page of the page set*/
         public void first() { 
         selectmethod();
          // updateSearchItemsMap();
           setCon.first();   
           init();
         
         }
         
         /** returns the last page of the page set*/
         public void last() {
          selectmethod();
          // updateSearchItemsMap();
           setCon.last();
            init();
         }
         
         /** returns the previous page of the page set*/
         public void previous() {
          selectmethod();
          // updateSearchItemsMap();
           setCon.previous();
           init();
         }
         
         /** returns the next page of the page set*/
         public void next() {
         selectmethod();
         //  updateSearchItemsMap();
           setCon.next();
           init();
         }
         public void selectmethod() {
              system.debug('wrapper size :' + wrapperRecordList);
              if(!wrapperRecordList.isEmpty())
              for(WrapperClass wrp : wrapperRecordList){
              paginationmap.put(wrp.contactRecord.id, wrp);          
              if(wrp.isSelected ){
              mapHoldingSelectedRecords.put(wrp.contactRecord.id, wrp);
             }
             if(wrp.isSelected == false && mapHoldingSelectedRecords.containsKey(wrp.contactRecord.id)){
             mapHoldingSelectedRecords.remove(wrp.contactRecord.id);
              }
 
            }  
              
                         system.debug(mapHoldingSelectedRecords.size());
            
            }

wanted to count total number of records 

public List<Contact> contactsize = new List<Contact>();
     global void execute(Database.BatchableContext bc,  List<Contact> Scope){
          conupdate = new List<Contact>();
       system.debug('calling update check execute');
    
       For(Contact c: Scope){  
            c.Direct_send__c= true;
              conupdate.add(c);   
           }
       system.debug('contact list' + conupdate.size());  
         contactsize.addAll(conupdate);
         update conupdate;
     }  
    global void finish(Database.BatchableContext bc){
     system.debug('contacts size :' + contactsize.size());
        recordcount = contactsize.size();
Not refreshing the wrapper list here
public class TouchContact{

    //Variable declaration
    public Contact con {
    get;
    set;
    }
    Public Integer noOfRecords{get; set;}
    Public Integer size{get;set;}
    public boolean selectedAllProperties {
    get;
    set;
    }
    public List<contactWrapperCls> lstConWrapper {            // overall list
    get;
    set;
    }
    public List <contactWrapperCls> lstConWrapper1 {          // page list
    set;
    get;
    }
    public List <contactWrapperCls> lstConWrapper2 {          // Selected records list
    set;
    get;
    }
    public set < id > DummyIds;                               // Dummy object Ids
    public List < SelectOption > options {
    get;
    set;
    }
    public List < SelectOption > operatorOptions {
    get;
    set;
    }
    public static string selectedOperatorOption {
    get;
    set;
    }
    public static string SelectedOption {
    get;
    set;
    }
    public string enteredText {
    get;
    set;
    }
    public string selectedDataType {
    get;
    set;
    }
    public Map < string, string > checkDataTypeMap {
    get;
    set;
    }
    Public List<SelectOption> Slist {
    get;
    set;
    }
    public string selectedvalue {
    get;
    set;
    }
    public List<Contact> conlist{
    get;
    set;
    }
    Public List < Contact > Createconlist {
    set;
    get;
    }
 
    public Map<id,Contact> Cmap{
    get;
    set;
    }
    public Set<Id> Keys{
    get;
    set;
    }
    public date dat{
    get;
    set;
    }
    public date to{
    get;
    set;
    }
    public ApexPages.StandardSetController stdCtrl{get;set;}
    public Integer counter = 0; //TO track the number of records parsed
    public Integer limitSize = 100; //Number of records to be displayed
    public Integer totalSize {
    set;
    get;
    }
    
     
    public transient Map < String, Schema.SObjectType > schemaMap = Schema.getGlobalDescribe();
    
    public TouchContact(ApexPages.StandardController stdController){
         
      con =  new contact();
      options = new List < SelectOption > ();
      checkDataTypeMap = new Map < String, string > ();
      operatorOptions = new List < SelectOption > ();
    
      
  //To fetch the Contact fields by Describe call
      Selectoption sv = new SelectOption('--Please Select--', '--Please Select--');
      Options.add(sv);
      Map < String, Schema.SObjectField > ContactFieldsMap = SchemaMap.get('Contact').getDescribe().fields.getMap();
      for (Schema.SObjectField sField: ContactFieldsMap.Values()) {      
          schema.describefieldresult fieldName = sfield.getDescribe();
          Schema.DisplayType fielddataType = sfield.getDescribe().getType();
          string fieldType = string.valueOf(fielddataType);
          SelectOption sp = new SelectOption(fieldName.getName(), fieldName.getName());
          checkDataTypeMap.put(fieldName.getName(), fieldType);
          options.add(sp);
          options.sort();      
      }  
  //Add the filter conditons feteched from Custom settings to show in picklist
      SelectOption selOpt = new SelectOption('--Please Select--', '--Please Select--');
      operatorOptions.add(selOpt);
      List < CustomCondition1__c > filetConditions = CustomCondition1__c.getall().values();
      for (CustomCondition1__c Fcon: filetConditions) {      
          SelectOption Fsp = new SelectOption(Fcon.Name, Fcon.Name);
          operatorOptions.add(Fsp);
          operatorOptions.sort();          
     }
  }
 
  public Integer countr = 0 ; 
  public void Search(){
      Integer pageSize ;
      size = 10; 
      Integer totsize = 500;  
      Integer pageNumber ; 
      system.debug('From Date :******** '+con.datefield__c);
      system.debug('TO Date :******** '+con.To_date__c);
      system.debug('LastSent Date :******** '+con.Last_Sent_Date__c);
      system.debug('SelectedOption :******** '+SelectedOption);
      system.debug('Selected Operator :******** '+selectedOperatorOption);
        lstConWrapper = new List<contactWrapperCls>(); 
      lstConWrapper1 = new List<contactWrapperCls>();
      lstConWrapper2 = new List<contactWrapperCls>();
      
      datetime fromDate = con.datefield__c;
      datetime toDate = con.To_date__c;
      Date lastDate30 = System.today().addDays(-30);
      Date lastDate60 = System.today().addDays(-60);
      Date lastDate90 = System.today().addDays(-90);
      Cmap = new map<Id,contact>();
      conlist = new List<Contact>();
      string soql = 'SELECT id,LastName,AssistantName,AssistantPhone,Birthdate,Department,Description,Email,Fax,';
      soql      += 'HomePhone,MailingAddress,MailingCity,MailingCountry,MailingPostalCode,MailingState,datefield__c,To_date__c,' ;
      soql      += 'MailingStreet,MobilePhone,Name,firstname,OtherAddress,OtherCity,OtherCountry,OtherPhone,OtherPostalCode,';
      soql      += 'OtherState,OtherStreet,Account.Name,LastModifiedDate,Phone,Title,Mail_Sent_Date__c,' ;
      soql      += '(SELECT Assistant_Name__c,Assistant_Phone__c,Birthdate__c,Contact__c,CreatedById,'
                + 'CreatedDate,Department__c,Description__c,Email__c,Fax__c,First_Name__c,Home_Phone__c,Id,IsDeleted,Mailing_City__c,'
                +'Mailing_Country__c,Mailing_State_Province__c,Mailing_Street__c,Mailing_Zip_Postal_Code__c,Mobile_Phone__c,Name,'
                +'Other_City__c,Other_Country__c,Other_Phone__c,Other_State_Province__c,Other_Street__c,Other_Zip_Postal_Code__c,'
                +'OwnerId,Phone__c,Title__c from Cons__r) From Contact  ';
      string whereConditions = 'where ';
      string resultQuery = '';
      if(con.datefield__c !=null && con.To_date__c !=null){          
          resultQuery = soql + whereConditions+   ' LastModifiedDate >= :fromDate AND LastModifiedDate <= :toDate' ;
        
      }
      if(Con.Last_Sent_Date__c !='--None--'){
          resultQuery =  getLastsentDate(Con.Last_Sent_Date__c ,resultQuery) ;
      }
      if(string.isNotBlank(SelectedOption) && string.isNotBlank(selectedOperatorOption) && string.isNotBlank(enteredText)){
          resultQuery = getOperatorSelection(SelectedOption,selectedOperatorOption,resultQuery,enteredText) ;
      }
      //Hit the database
         
          conlist = database.query(resultQuery  +' LIMIT 500' ); 
                 
          system.debug('conlist : ' + conlist);
          
          stdCtrl =  new ApexPages.StandardSetController(conlist);
          stdCtrl.setPageSize(size);               
          noOfRecords = stdCtrl.getResultSize();
          pageNumber = stdCtrl.getPageNumber();
          system.debug(pageNumber + 'page Number');
         system.debug('noOfRecords '+ noOfRecords); 
         
           for(contact con :(List<contact>)stdCtrl.getRecords()){
                lstConWrapper.add(new contactWrapperCls(false,con));  
                }
              
        system.debug('lstConWrapper is 9((((((((((((:'+lstConWrapper.size());      
    }
    private string getLastsentDate(string lastSentDate,string dynamicSoql){
        
        if(con.Last_Sent_Date__c =='30 days')
            dynamicSoql = dynamicSoql + ' and Mail_Sent_Date__c < :lastDate30';
        if(con.Last_Sent_Date__c =='60 days')
            dynamicSoql = dynamicSoql + ' and Mail_Sent_Date__c < :lastDate60';
        if(con.Last_Sent_Date__c =='90 days')
            dynamicSoql = dynamicSoql + ' and Mail_Sent_Date__c < :lastDate90';
        if(con.Last_Sent_Date__c =='Contacted')
            dynamicSoql = dynamicSoql + ' and Mail_Sent_Date__c != null';
        if(con.Last_Sent_Date__c =='Not Contacted')
            dynamicSoql = dynamicSoql + ' and Mail_Sent_Date__c = null';
        
        return dynamicSoql;
    }
    private string getOperatorSelection(string SelectedOption,string selectedOperator,string dynamicSoql,string enteredText){
        string selectedDataType = checkDataTypeMap.get(SelectedOption);
        if (selectedOperatorOption == 'Equal to'){
            if(selectedDataType == 'BOOLEAN' || selectedDataType == 'Id')
                dynamicSoql = dynamicSoql + ' AND '+ SelectedOption + '= ' + enteredText; 
            else
                dynamicSoql = dynamicSoql + ' AND '+ SelectedOption + '= ' + '\'' + enteredText + '\'';
        }
        if (selectedOperatorOption == 'Not equal to'){
            if(selectedDataType == 'BOOLEAN' || selectedDataType == 'Id')
                dynamicSoql = dynamicSoql +' AND' + SelectedOption + '!= ' + enteredText;
            else
                dynamicSoql = dynamicSoql + ' AND '+ SelectedOption + '!= ' + '\'' + enteredText + '\'';
        }
        return dynamicSoql;        
    }
    
    //=============pagination test==================//
   
 
    //==============================================//
    
  
    
   
    
    //================= Selected Records==============//
    
    public pageReference selectedRecords() {
        Map<Id, Contact>contactmap = New Map<Id, Contact>();
        List<Contact>contactscupdate = New List<Contact>();
        Set<id>lstSelectedCons = new set<Id>();
        List<Contact>SelectedDc = new List < Contact > ();
        if(!lstConWrapper2.isEmpty()){
        for(contactWrapperCls contactWrapperClsobj : lstConWrapper2){
           if(contactWrapperClsobj.isSelected == true){
           system.debug(contactWrapperClsobj);
     //       lstSelectedCons.add(contactWrapperClsobj.Id);
     //       SelectedDc.add(contactWrapperClsobj);
    }           
    }     
    }     
        return null;
    }
    
    //=================Wrapper Class==================//
    
    public class contactWrapperCls{
        public boolean isSelected {get;set;}        
        public contact objContact {get;set;}
        
        public contactWrapperCls(boolean isSel,contact con){
            this.isselected = isSel;
            this.objContact = con;            
        }
    }
    public void selectAllChks(){
        selectedAllProperties = true;
        
    }  
     public pageReference refresh() {
        //stdCtrl = null;
        //getAccounts();
        stdCtrl.setPageNumber(1);
        return null;
    }
 
     
    public Boolean hasNext {
        get {
            return stdCtrl.getHasNext();
        }
        set;
    }
    public Boolean hasPrevious {
        get {
            return stdCtrl.getHasPrevious();
        }
        set;
    }
   
    public Integer pageNumber {
        get {
            return stdCtrl.getPageNumber();
        }
        set;
    }
   
    public void first() {
        stdCtrl.first();
    }
   
    public void last() {
        stdCtrl.last();
    }
   
    public void previous() {
        stdCtrl.previous();
    }
   
    public void next() {
      stdCtrl.next();
        //system.debug('hello%%%%%%%%%%%%%% :'+stdCtrl.);
    }
 
}

==================vf=======

<apex:page standardController="Contact" docType="Html-5.0" sidebar="false" extensions="TouchContact" >
    <style>
        .spacer15 {
          height: 10px;
        }
    </style>
   <head>      
       <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>       
   </head>
   <div class="container">
      <ul class="nav nav-pills">
         <li><a data-toggle="pill" href="#adminSetup">Admin Setup</a></li>
         <li><a data-toggle="pill" href="#sendEmail">Send Email</a></li>
      </ul>
      <div class="tab-content">
         <div id="adminSetup" class="tab-pane fade in active">
         <br/>
         <br/>
         <h4>Installation Steps </h4> <br/>
         <p>
         1. Go to sites --> Click on New -->
         </p>
         </div>
         <div id="sendEmail" class="tab-pane fade">
          <br/>
          <br/>
            <apex:form > 
                 <apex:actionFunction name="isSelectAllItem" action="{!selectAllChks}"  rerender="pb">
                    <apex:param name="isSelectedALL" value="" assignTo="{!selectedAllProperties}"/>
                </apex:actionFunction>
                   <div class="row">                                                                  
                       <div class="col-sm-2" >
                           <label for="FrmDate">Form Date:</label> 
                        </div> 
                         <div class="col-sm-4" >  
                         <apex:inputField value="{!Con.datefield__c}" styleClass="form-control" style="width:50%;" />                                                                                 
                        </div> 
                                                                    
                       <div class="col-sm-2" >
                          <label for="ToDate">To Date:</label> 
                         </div>
                         <div class="col-sm-4">
                         <apex:inputField value="{!Con.To_date__c}"  styleClass="form-control" style="width:50%;" />                                    
                     </div>
                   </div> 
                 <div class="spacer15">
                </div>
                <div class="row">
                     <div class="col-sm-2" >
                        <label for="LsentDate">Last Sent Date:</label>
                     </div>
                        <div class="col-sm-4" >
                           <apex:inputField value="{!Con.Last_Sent_Date__c}"  styleClass="form-control" style="width:50%;" />
                        </div>    
                         <div class="col-sm-2" >
                        <label for="LsentDate"> Enable Direct Send:</label>
                     </div>
                        <div class="col-sm-4" >
                           <apex:inputCheckbox value="{!Con.Direct_send__c}"  styleClass="form-control" style="width:50%;" />
                        </div>                  
                </div>
                 <div class="spacer15">
                </div>
                <div class="row">  
                    <div class="col-sm-2">
                        <label for="sField">Select Field:</label>  
                    </div>
                     <div  class="col-sm-4">                                                    
                         <apex:selectList value="{!SelectedOption}" size="1" styleClass="form-control" style="width:50%;"  >
                           <apex:selectOptions value="{!Options}"  />
                        </apex:selectList> 
                            </div> 
                     <div class="col-sm-2" >
                                         
                          <apex:selectList value="{!selectedOperatorOption}" size="1"  styleClass="form-control"  >
                           <apex:selectOptions value="{!operatorOptions}" >                  
                           </apex:selectOptions>
                        </apex:selectList>
                     </div>  
                    <div class="col-sm-2" >
                        <apex:inputText value="{!enteredText}" styleClass="form-control"   />
                     </div>
                </div> 
                 <div class="spacer15">
                 </div>
                   <div class="spacer15">
                </div>
                 <div style="float:None;align:center;margin-left:40%; "> 
                   <apex:commandButton value="Search" action="{!Search}" styleClass=" btn btn-primary" style="background:#236FBD; width:100px; font-size: 12px;" reRender="ContactList"  status="pageStatus" >    
                    <apex:actionStatus id="pageStatus">
                    <apex:facet name="start">
                    <apex:outputPanel >
                    <img src="/img/loading32.gif" width="25" height="25" />
                    <apex:outputLabel value="Loading..."/>
                    </apex:outputPanel>            
                    </apex:facet>
                    </apex:actionStatus>                      
                   </apex:commandButton>
                  </div> 
                    <div class="spacer15">
                </div>
                <div class="container" >
                 <apex:pageBlock id="ContactList" >             
                  <apex:outputPanel rendered="{! IF(lstConWrapper1!= null && lstConWrapper1.size !=0 , true, false)}">
                    <br/>
                <!-- count of selected items
                    <apex:outputLabel value="Total Number of Records :{!totalSize } " /> -->
                    </apex:outputPanel>
                    <br/> 
                <!--    
                    <apex:outputPanel id="ContactList" 
      rendered="{!conlist!= null && conlist.size > 0}" 
     >
         
    
   <apex:commandButton value="<<" disabled="{!DisablePreviousAccount}" 
        action="{!previousFirstAccount}" 
        reRender="ContactList,ps" styleclass="bluerund">  
   </apex:commandButton>

   <apex:commandButton value="<" disabled="{!DisablePreviousAccount}" 
         action="{!previousAccount}" 
       reRender="ContactList,ps"  styleclass="bluerund">  
   </apex:commandButton>

   <apex:commandButton value=">" disabled="{!DisableNextAccount}" 
         action="{!nextAccount}" 
       reRender="ContactList,ps"  styleclass="bluerund">
   </apex:commandButton>

   <apex:commandButton value=">>" disabled="{!DisableNextAccount}"
         action="{!nextLastAccount}"
       reRender="ContactList,ps"  styleclass="bluerund">  
   </apex:commandButton> 
   
   
                                     
</apex:outputPanel>
         -->              
      
                  <apex:pageBlockTable value="{!lstConWrapper}"  var="objCon" rendered="{! IF(lstConWrapper!= null && lstConWrapper.size !=0 , true, false)}">
                     <apex:column >
                        <apex:facet name="header"  >                            
                            <apex:inputCheckbox value="{!selectedAllProperties}" styleClass="checkbox" onclick="selectAllCheckboxes(this)" id="Headercheckbox" />                               
                        </apex:facet>                         
                           <apex:inputCheckbox value="{!objCon.isSelected}" styleClass="checkbox"   onclick="doCheckboxChange(this,'{!objCon.objContact.Id}')"  />                                                  
                     </apex:column>
                     <apex:column value="{!objCon.objContact.lastname}"/>
                     <apex:column value="{!objCon.objContact.firstname}"/>
                      <apex:column value="{!objCon.objContact.Account.Name}"/>
                     <apex:column value="{!objCon.objContact.email}"/>
                      <apex:column value="{!objCon.objContact.LastModifiedDate}"/>
                  </apex:pageBlockTable>    
                 <apex:pageBlockButtons >
                    <apex:commandButton value="Send Mail" action="{!selectedRecords}" reRender="ContactList"/>
                 </apex:pageBlockButtons>
                     <apex:panelgrid columns="7" rendered="{!if(lstConWrapper !=null,true,false)}" >
                <apex:commandbutton action="{!first}" disabled="{!!hasPrevious}" rerender="ContactList" status="fetchStatus" title="First Page" value="|<"></apex:commandbutton>
                <apex:commandbutton action="{!previous}" disabled="{!!hasPrevious}" rerender="ContactList" status="fetchStatus" title="Previous Page" value="<"></apex:commandbutton>
                <apex:commandbutton action="{!next}" disabled="{!!hasNext}" rerender="ContactList" status="fetchStatus" title="Next Page" value=">"></apex:commandbutton>
                <apex:commandbutton action="{!last}" disabled="{!!hasNext}" rerender="ContactList" status="fetchStatus" title="Last Page" value=">|"> </apex:commandbutton>
                 <apex:outputtext >{!(pageNumber * size)+1-size}-{!IF((pageNumber * size)>noOfRecords, noOfRecords,(pageNumber * size))} of {!noOfRecords}</apex:outputtext>
               <apex:commandbutton action="{!refresh}" rerender="pb" status="fetchStatus" title="Refresh Page" value="Refresh"></apex:commandbutton> 
                <apex:outputpanel style="color: #4aa02c; font-weight: bold;">
                    <apex:actionstatus id="fetchStatus" starttext="Fetching..." stoptext="">
                </apex:actionstatus>
             </apex:outputpanel>
           </apex:panelgrid>
            
        
         
               </apex:pageBlock>
                    
             </div>
            </apex:form>
         </div>
      </div>
   </div>
   <script>     
      function selectAllCheckboxes(obj){
        
        $(".checkbox").each(function(index, item){
            item.checked = obj.checked;
        });
        isSelectAllItem(obj.checked);
    }
    function doCheckboxChange(cb,itemId)
    {
        if(cb.selected==true){
            aSelectItem(itemId);
        }
        else{
            aDeselectItem(itemId);
        }        
    }  
   </script>
</apex:page>
I have to send 1 lakh emails in one transaction, for that i used batch, but day limit is 5000, how can i continue that rest of the emails to next day
public class contactSend {
 public set<Id> lstSelectedCons {get;set;}
 public Date dat {
  set;
  get;
 }
 public Date To {
  set;
  get;
 }
 public Boolean showCalendarField {
  get;
  set;
 }
 public Date calendarFieldVal {
  get;
  set;
 }
 public List < Contact > SelectedDc {
  set;
  get;
 }
 public List < WrapDummy > wdlist {
  set;
  get;
 }
 public List < WrapDummy > wdlist1 {
  set;
  get;
 }
 public List < WrapDummy > wdlist2 {
  set;
  get;
 }

 public transient List < Contact > ct {
  set;
  get;
 }
 public string selectedvalue {
  set;
  get;
 }
 public id DummyconId {
  set;
  get;
 }
 public Map < string, id > mMap {
  set;
  get;
 }
 public string dummymail {
  set;
  get;
 }
 public string result {
  set;
  get;
 }
 public String messageBody;
 public Integer totalSize {
  set;
  get;
 }
 public Integer totalPages {
  set;
  get;
 }
 public Set < String > Scon;
 public set < id > setIds;
 public string selectedDataType {
  set;
  get;
 }
 public List < contact > ContactsToShow {
  get;
  set;
 }
 public Integer counter = 0; //TO track the number of records parsed
 public Integer limitSize = 100; //Number of records to be displayed
 //Integer totalSize =0;

 //pagination Standard set
 /**public Apexpages.Standardsetcontroller con;
    
 public Map<Id,Decimal> quantityMap {set;get;}
 public Set<Id> SelectedPropertyIds {set;get;}
 public string ContextItem {set;get;}
 public string ContextItemValue {set;get;} **/
 public Boolean SelectedAllProperties {
  set;
  get;
 }

 //List to show the limited records on the page
 /**  public List<WrapDummy> ContactsToShow {get;set;}
   public List<wrapDummy> currentrecords {get;set;}
   Integer counter = 0;//TO track the number of records parsed
   Integer limitSize = 10;//Number of records to be displayed
   Integer totalSize {set;get;} //To Store the total number of records available

  **/
 public List < Dummy_Contact__c > dummylist {
  set;
  get;
 }

 Public List < Contact > conlist {
  set;
  get;
 }
 public List < Dummy_Contact__c > dclist {
   set;
   get;
  }
  // filter condition variables
 public List < SelectOption > options {
  get;
  set;
 }
 public List < SelectOption > operatorOptions {
  get;
  set;
 }
 public static string selectedOperatorOption {
  get;
  set;
 }
 public static string SelectedOption {
  get;
  set;
 }
 public string enteredText {
  get;
  set;
 }
 public Map < string, string > checkDataTypeMap {
  get;
  set;
 }
 public List < contact > lstContacts {
  get;
  set;
 }
 public transient Map < String, Schema.SObjectType > schemaMap = Schema.getGlobalDescribe();

 public contactSend() {

  options = new List < SelectOption > ();
  checkDataTypeMap = new Map < String, string > ();
  operatorOptions = new List < SelectOption > ();
  //To fetch the Contact fields by Describe call
  Selectoption sv = new SelectOption('--Please Select--', '--Please Select--');
  Options.add(sv);

  Map < String, Schema.SObjectField > ContactFieldsMap = SchemaMap.get('Contact').getDescribe().fields.getMap();
  for (Schema.SObjectField sField: ContactFieldsMap.Values()) {
   schema.describefieldresult fieldName = sfield.getDescribe();
   Schema.DisplayType fielddataType = sfield.getDescribe().getType();
   string fieldType = string.valueOf(fielddataType);
   SelectOption sp = new SelectOption(fieldName.getName(), fieldName.getName());
   checkDataTypeMap.put(fieldName.getName(), fieldType);
   options.add(sp);
   options.sort();
  }  
  //Add the filter conditons feteched from Custom settings to show in picklist
  SelectOption selOpt = new SelectOption('--Please Select--', '--Please Select--');
  operatorOptions.add(selOpt);

  List < CustomCondition1__c > filetConditions = CustomCondition1__c.getall().values();
  for (CustomCondition1__c Fcon: filetConditions) {
   SelectOption Fsp = new SelectOption(Fcon.Name, Fcon.Name);
   operatorOptions.add(Fsp);
   operatorOptions.sort();
  }
 }

 public PageReference createcon() {

  conlist = [SELECT id, LastName, AssistantName, AssistantPhone, Birthdate, Department, Description, Email, Fax, HomePhone, MailingAddress,
   MailingCity, MailingCountry, MailingPostalCode, MailingState, MailingStreet, MobilePhone, Name, OtherAddress, OtherCity,
   OtherCountry, OtherPhone, OtherPostalCode, OtherState, OtherStreet, Phone, Title,
       (SELECT id, email__c, Assistant_Name__c, Assistant_Phone__c, Birthdate__c, Contact__c,
        Department__c, Description__c, Fax__c, First_Name__c, Home_Phone__c, Mailing_City__c, Mailing_Country__c,
        Mailing_State_Province__c, Mailing_Street__c, Mailing_Zip_Postal_Code__c, Mobile_Phone__c,
        Other_City__c, Other_Country__c, Other_Phone__c, Other_State_Province__c, Other_Street__c,
        Other_Zip_Postal_Code__c, Phone__c, Title__c from Cons__r)
   From Contact where id in :lstSelectedCons limit 9999 
  ];

  list < Dummy_Contact__c > listDummyContactMain = new list < Dummy_Contact__c > ();
  list < Dummy_Contact__c > listDummyContactNew = new list < Dummy_Contact__c > ();

  for (Contact c: conlist) {
   if (c.Cons__r.size() == 0) {

    Dummy_Contact__c Dcobj = new Dummy_Contact__c();
    Dcobj.Name = c.LastName;
    Dcobj.Assistant_Name__c = c.AssistantName;
    Dcobj.Assistant_Phone__c = c.AssistantPhone;
    Dcobj.Birthdate__c = c.Birthdate;
    Dcobj.Description__c = c.Description;
    Dcobj.Department__c = c.Department;      
    Dcobj.Email__c = c.Email;
    Dcobj.Fax__c = c.Fax;
    Dcobj.Mailing_City__c = c.MailingCity;
    Dcobj.Mailing_Country__c = c.MailingCountry;
    Dcobj.Mailing_Zip_Postal_Code__c = c.MailingPostalCode;
    Dcobj.Mailing_State_Province__c = c.MailingState;
    Dcobj.Mailing_Street__c = c.MailingStreet;
    Dcobj.Other_City__c = c.OtherCity;
    Dcobj.Other_Country__c = c.OtherCountry;
    Dcobj.Other_Phone__c = c.OtherPhone;
    Dcobj.Other_Zip_Postal_Code__c = c.OtherPostalCode;
    Dcobj.Other_State_Province__c = c.OtherState;
    Dcobj.Other_Street__c = c.OtherStreet;
    Dcobj.Phone__c = c.Phone;
    Dcobj.Home_Phone__c = c.HomePhone;
    Dcobj.Mobile_Phone__c = c.MobilePhone;
    Dcobj.Title__c = c.Title;
    Dcobj.Contact__c = c.id;

    listDummyContactNew.add(Dcobj);

    //insert Dcobj;

   } else {
    listDummyContactMain.add(c.Cons__r[0]);
   }
  }
  if (!listDummyContactNew.isEmpty())
  try{
   insert listDummyContactNew;
   }
   catch(Exception e){
   system.debug(e.getMessage());
   }
  setIds = new set < id > ();
  listDummyContactMain.addAll(listDummyContactNew);

  for (Dummy_Contact__c dummy: listDummyContactMain) {
   String ids = '';
   ids += '\'';
   ids += String.valueOf(dummy.id);
   ids += '\'';
   //setIds.add(ids);
   setIds.add(dummy.id);
  }

  return null;
 }

 public pageReference getTeamMembers() {
  getslist();
  return null;
 }

 public List < SelectOption > getslist() {
  List < SelectOption > Slist = new List < SelectOption > ();
  Slist.add(new SelectOption('Not Contacted', 'Not Contacted'));
  Slist.add(new SelectOption('Contacted', 'Contacted'));
  Slist.add(new SelectOption('30 days', '30 days'));
  Slist.add(new SelectOption('60 days', '60 days'));
  Slist.add(new SelectOption('90 days', '90 days'));

  return Slist;
 }

 public pageReference Search() {
  ct = new List < contact > ();
  result = null;
  Date lastDate30 = System.today().addDays(-30);
  Date lastDate60 = System.today().addDays(-60);
  Date lastDate90 = System.today().addDays(-90);
  wdlist = new List < WrapDummy > ();
  wdlist1 = new List < WrapDummy > ();
  wdlist2 = new List < WrapDummy > ();

  string soql = 'SELECT id,LastName,AssistantName,AssistantPhone,Birthdate,Department,Description,Email,Fax,' + +
   'HomePhone,MailingAddress,MailingCity,MailingCountry,MailingPostalCode,MailingState,' + +
   'MailingStreet,MobilePhone,Name,firstname,OtherAddress,OtherCity,OtherCountry,OtherPhone,OtherPostalCode,' + +
   'OtherState,OtherStreet,Account.Name,LastModifiedDate,Phone,Title,Mail_Sent_Date__c,' + +
   '(SELECT Assistant_Name__c,Assistant_Phone__c,Birthdate__c,Contact__c,CreatedById,CreatedDate,Department__c,Description__c,Email__c,Fax__c,First_Name__c,Home_Phone__c,Id,IsDeleted,Mailing_City__c,Mailing_Country__c,Mailing_State_Province__c,Mailing_Street__c,Mailing_Zip_Postal_Code__c,Mobile_Phone__c,Name,Other_City__c,Other_Country__c,Other_Phone__c,Other_State_Province__c,Other_Street__c,Other_Zip_Postal_Code__c,OwnerId,Phone__c,Title__c from Cons__r) From Contact where   ';
  string whereConditions = '';

  string resultQuery = '';
  if (string.isNotBlank(SelectedOption)) {
   whereConditions = SelectedOption;
  }
  if (string.isNotBlank(selectedOperatorOption)) {
   if (selectedOperatorOption == 'Equal to') {
    selectedOperatorOption = '=';
   } else {
    if (selectedOperatorOption == 'Not equal to') {
     selectedOperatorOption = '!=';
    }
   }
   whereConditions = whereConditions + ' ' + selectedOperatorOption;
   system.debug('enteredText ************ ' + enteredText);
   if (string.isNotBlank(enteredText) || calendarFieldVal != null) {
    string selectedDataType = checkDataTypeMap.get(SelectedOption);
    if (selectedDataType == 'BOOLEAN') {
     whereConditions = whereConditions + ' ' + enteredText;
    }
    if (selectedDataType == 'STRING')
     whereConditions = whereConditions + ' ' + '\'' + enteredText + '\'';
    if (selectedDataType == 'DATE') {
     whereConditions = whereConditions + ' ' + calendarFieldVal;
    }
   }
   if (selectedvalue == 'Not Contacted') {
    if (selectedOperatorOption == 'Select Value' || enteredText == '') {
     resultQuery = soql + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c = null';
        system.debug('hello1 :'+resultQuery);
    } else {
     resultQuery = soql + whereConditions + ' AND  ' + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c = null';
        system.debug('hello2 :'+resultQuery);
    }
    ct = database.query(resultQuery + ' Limit 10000');
       system.debug('ct sixe is1  :'+ct);
   }
  }
  if (selectedvalue == 'Contacted') {
   if (selectedOperatorOption == '--Please Select--' || enteredText == '') {
    resultQuery = soql + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c != null';

   } else {
    resultQuery = soql + whereConditions + ' AND  ' + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c != null';
   }
   ct = database.query(resultQuery + ' Limit 10000');
      system.debug('ct sixe is2  :'+ct);
  } else if (selectedvalue == '30 days') {
   if (selectedOperatorOption == 'Select Value' || enteredText == '') {
    resultQuery = soql + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate30';

   } else {
    resultQuery = soql + whereConditions + ' AND  ' + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate30';
   }
   ct = database.query(resultQuery + ' Limit 10000');
      system.debug('ct sixe is3  :'+ct);
  } else if (selectedvalue == '60 days') {
   if (selectedOperatorOption == 'Select Value' || enteredText == '') {
    resultQuery = soql + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate60';

   } else {
    resultQuery = soql + whereConditions + ' AND  ' + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate60';
   }
   ct = database.query(resultQuery + ' Limit 10000');
    system.debug('ct sixe is4  :'+ct);
  } else if (selectedvalue == '90 days')
  {
       if (selectedOperatorOption == 'Select Value' || enteredText == '') {
        resultQuery = soql + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate90';
    
       } else {
        resultQuery = soql + whereConditions + ' AND  ' + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate90';
       }
       ct = database.query(resultQuery + ' Limit 10000');
        system.debug('ct sixe is5  :'+ct);
  }

  dummylist = new List < Dummy_Contact__c > ();
  if (!ct.isEmpty()) {
   for (Contact cf: ct) {       
    for (Dummy_Contact__c df: cf.Cons__r) {
     DummyconId = df.id;
     dummymail = df.email__c;
     dummylist.add(df);
    }
   }   
  }
     for (Contact dt: ct)
        wdlist.add(new WrapDummy(dt));
  totalSize = wdlist.size();
     system.debug('total size is :'+totalSize);
  if ((counter + limitSize) <= totalSize) {
   for (Integer i = 0; i < limitSize; i++) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  } else {
   for (Integer i = 0; i < totalSize; i++) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  }

  totalPages = Integer.valueOf(Math.ceil(totalSize / (Double) limitSize));
  return null;
 }

 public void beginning() {
system.debug('wdlist is :'+wdlist);
 
  wdlist1.clear();
  counter=0;
  if ((counter + limitSize) <= totalSize) {      
   for (Integer i = 0; i < limitSize; i++) {
       if(!wdlist.isEmpty()){
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
       }
   }
  } else {
   for (Integer i = 0; i < totalSize; i++) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  }
 }
 public void nextP() {


  if (selectedAllProperties)
   selectedAllProperties = true;


  else
   selectedAllProperties = false;

  wdlist1.clear();
  counter = counter + limitSize;

  if ((counter + limitSize) <= totalSize) {
   for (Integer i = counter; i < (counter + limitSize); i++) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  } else {
   for (Integer i = counter; i < totalSize; i++) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  }

 }
 public void previousP() {
  if (selectedAllProperties)
   selectedAllProperties = true;

  else
   selectedAllProperties = false;


  wdlist1.clear();
  counter = counter - limitSize;
  for (Integer i = counter; i < (counter + limitSize); i++) {
   if (!wdlist.isEmpty()) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  }

 }
 public void lastP() {

system.debug('wdlist is :'+wdlist);
  wdlist1.clear();
  if (math.mod(totalSize, limitSize) == 0)
   counter = limitSize * ((totalSize / limitSize) - 1);
  else if (math.mod(totalSize, limitSize) != 0)
   counter = limitSize * ((totalSize / limitSize));
system.debug('counter :'+counter);
     system.debug('totalSize :'+totalSize);
  for (Integer i = counter - 1; i < totalSize - 1; i++) {
   if (!wdlist.isEmpty()) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  }
 }
 public Boolean getDisableNext() {

  if ((counter + limitSize) >= totalSize)
   return true;
  else
   return false;
 }

 public Boolean getDisablePrevious() {

  if (counter == 0)
   return true;
  else
   return false;
 }
 public PageReference processselected() {
  Set < String > scon = new Set < String > ();
  lstSelectedCons = new set<Id>();
  SelectedDc = new List < Contact > ();
  set < Contact > ncts = new set < Contact > ();

  List < contact > updatecons = new List < Contact > ();
  if (!wdlist2.isEmpty()) {
   for (WrapDummy WrapDummyobj: wdlist2) {
    if (WrapDummyobj.selected == true) {
        lstSelectedCons.add(WrapDummyobj.Dcc.Id);
     SelectedDc.add(WrapDummyobj.Dcc);
     
     for (contact cts: SelectedDc) {
      cts.Mail_Sent_Date__c = Date.today();
      ncts.add(cts);
      // setids.add(cts.id);
    
     }
     //update ncts;                   
    }
   }

   if (!ncts.isEmpty()) {
    list < Contact > listNcts = new list < Contact > ();
    listNcts.addAll(ncts);
   }
   createcon();
  }
 // EmailTemplate templateId = [Select id from EmailTemplate where name = 'Sales: New Customer Email'];
  ContactUpdateURL__c mc = ContactUpdateURL__c.getall().values();
  string urlcode = mc.URLforContactUpdate__c;
  Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();

  if (SelectedDc.size() > 9) {
   for (contact c: SelectedDc) {
    scon.add(String.valueOf(c.id));
    system.debug(c.id);
    system.debug(c.cons__r);
     
    string cEmail = c.Email;
  
   }

   mailsend objmailsend = new mailsend();
   objmailsend.setIds = setIds;
   objmailsend.queryString = 'Select Assistant_Name__c,Assistant_Phone__c,Birthdate__c,Contact__c,CreatedById,CreatedDate,Department__c,Description__c,Email__c,Fax__c,First_Name__c,Home_Phone__c,Id,IsDeleted,Mailing_City__c,Mailing_Country__c,Mailing_State_Province__c,Mailing_Street__c,Mailing_Zip_Postal_Code__c,Mobile_Phone__c,Name,Other_City__c,Other_Country__c,Other_Phone__c,Other_State_Province__c,Other_Street__c,Other_Zip_Postal_Code__c,OwnerId,Phone__c,Title__c   From Dummy_Contact__c';

   Database.executeBatch(objmailsend);
   result = 'Sending Emails are under process';
   for (Contact cs: SelectedDc) {
    cs.Mail_Sent_Date__c = Date.today();
    updatecons.add(cs);
   }


  } else {
  system.debug('Email to send contact is : '+SelectedDc);
   for (contact c: SelectedDc) {

    scon.add(String.valueOf(c.id));
    string cEmail = c.Email;
       system.debug('be fore dummt contatc is : '+cEmail);
    for (Dummy_Contact__c dd: c.cons__r) {
        system.debug('dummt contatc is : '+dd);
     id DummyconId = dd.id;
     string dummyname = dd.name;
     string dummymail = dd.email__c;
     string dummytitle = dd.Title__c;
     string dummyphone = dd.phone__c;
     string dummymobile = dd.Mobile_Phone__c;
     string dummyfax = dd.fax__c;
     string dummymailingstreet = dd.Mailing_Street__c;
     string dummypostalcode = dd.Mailing_Zip_Postal_Code__c;
     string dummymailingcity = dd.Mailing_City__c;
     string dummystate = dd.Mailing_State_Province__c;
     string dummycountry = dd.Mailing_Country__c;
      
     
        
     message.toAddresses = new String[] {
      dummymail
     };
     
     message.setTargetObjectId(c.id);
     message.optOutPolicy = 'FILTER';
     message.subject = 'Touch Contact';
     messageBody = '<html><body>Dear ' + dummyname + ',<br><br> ' + +

      'I' + 'm currently updating my contact database and want to make sure I have your current data right.' + +

      'Could you have a quick look at below info? If you would like to change or update certain information, just click the ' + 'Update Now' + ' link on the bottom of the email and save your changes when done.<br> <br>' + +

      'Last Name:' + dummyname + '<br><br>' + +

      'Email:' + dummymail + '<br><br>' + +

      'Current company:' + +'<br><br>' + +

      'Title:' + dummytitle + '<br><br>' + +

      'Phone:' + dummyphone + '<br> <br>' + +

      'Mobile:' + dummymobile + '<br><br>' + +

      'Fax:' + dummyfax + '<br><br>' + +

      'Street:' + dummymailingstreet + '<br><br>' + +

      'Postalcode:' + dummypostalcode + '<br><br>' + +

      'City:' + dummymailingcity + '<br><br>' + +

      'State/Province:' + dummystate + '<br><br>' + +

      'Country:' + dummycountry + '<br><br><br>' + +

      '<a href="' + urlcode + DummyconId + '">Update Now</a>' + '<br><br><br>' + +

      'Many thanks in advance, ' + '<br>' + +


      '' + UserInfo.getlastname() + ' </html></body>';


     message.setHtmlBody(messageBody);
     message.setSaveAsActivity(false);
     Messaging.SingleEmailMessage[] messages = new List < Messaging.SingleEmailMessage > {
      message
     };
     Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
  system.debug('hello email :'+results);
     if (results[0].success) {
      c.Mail_Sent_Date__c = Date.today();
      updatecons.add(c);
      result = 'Email Sent';
     } else {
      string result = 'Email Not Sent';
     }
     break;
    }
   }

  }
  if(!updatecons.isEmpty())
  update updatecons;
  if (SelectedDc.isEmpty()) {
   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Please Select value'));
   return null;
  }

  pageReference pr = new PageReference('/apex/ContactMassMail1');
  pr.setRedirect(true);
  return pr;
 }

 public class WrapDummy {
  public Contact Dcc {
   set;
   get;
  }
  public Boolean selected {
   set;
   get;
  }
  public Decimal quantity {
   set;
   get;
  }
  public WrapDummy(Contact dt) {
   Dcc = dt;
   selected = false;
   quantity = 0;
  }
 }
 public pageReference enableCalendarTextBox() {
  string selDataType = checkDataTypeMap.get(SelectedOption);
  if (selDataType == 'DATE') {
   showCalendarField = true;
  } else {
   showCalendarField = false;
  }
  return null;
 }
}
=====================vf ==================
<apex:page showHeader="true" sidebar="false" controller="contactSend"  docType="html-5.0" id="mypage"  tabStyle="Contact" >
   <style type = "text/css">
      .pbs{
      color: red;
      }
   </style>
        
   <apex:form id="fm"  style="color:blue;">
      <apex:pageBlock id="pb" >
         <apex:pageMessages ></apex:pageMessages>
         <apex:pageBlockSection collapsible="false" id="pbs" >
            <apex:outputLabel >Last Modified Date From</apex:outputLabel>
            <apex:input type="date" value="{!dat}"    />
            <apex:outputLabel >Last Modified Date To</apex:outputLabel>
            <apex:input type="date"  value="{!to}"  />
            <apex:outputLabel >Contact Last sent</apex:outputLabel>
            <apex:selectList value="{!selectedvalue}" multiselect="false" size="1">
               <apex:selectOptions value="{!Slist}"></apex:selectOptions>
            </apex:selectList>
         </apex:pageBlockSection>
         <apex:pageBlock id="filt">
            <apex:outputLabel value="Select Field"  />
            :   
            <apex:selectList value="{!SelectedOption}" size="1">
                <apex:selectOptions value="{!Options}"  />
                  <apex:actionSupport event="onchange"  action="{!enableCalendarTextBox}" reRender="calendarField"   />              
            </apex:selectList>
            <apex:selectList value="{!selectedOperatorOption}" size="1" >
               <apex:selectOptions value="{!operatorOptions}" >                  
               </apex:selectOptions>
            </apex:selectList>   
             
            <apex:outputPanel id="calendarField">                
               <apex:input type="date" value="{!calendarFieldVal}"  style="{!if(showCalendarField,'display:hidden;', 'display:none')}"   />
                <apex:inputText value="{!enteredText}" style="{!if(showCalendarField,'display:none;', 'display:hidden')}" />                
            </apex:outputPanel>            
         </apex:pageBlock>
         <div class="pbs"  >
            <apex:pageBlockButtons location="bottom" > 
               <div style="float:None;align:center;margin-left:20%;"> 
               <apex:commandButton value="Search" action="{!Search}" status="actStatusId1" style="background:powderblue; width:100px;" rerender="table1, pb2,fm,pb,pi">
                  <apex:actionsupport event="oncomplete" rerender=" pb1"/>
               </apex:commandButton>
               </div>
            </apex:pageBlockButtons>
         </div>
      </apex:pageBlock>
      <apex:pageBlock id="pb1" >
         <apex:actionStatus id="actStatusId1" startText=" Processing the stuff "  >
            <apex:facet name="start" >
               <img src="/img/loading.gif" />
            </apex:facet>
         </apex:actionStatus>
         
      
          
        <apex:pageBlock title="Contact Details" id="noRec" rendered="{! IF(wdlist1!= null && wdlist1.size ==0 , true, false)}" >
            <apex:outputPanel >
                <h1>No Records Found </h1>
            </apex:outputPanel>
            </apex:pageBlock>
               <apex:pageBlockTable value="{!wdlist1}" var="c" id="table1"   > 
            <apex:column >
                    <apex:facet name="header">
                        <apex:inputCheckbox value="{!selectedAllProperties}" onclick="selectAllCheckboxes(this)" rendered="{! IF(wdlist1!= null && wdlist1.size !=0 , true, false)}" />
                    </apex:facet> 
                    <apex:inputCheckbox value="{!c.selected}" styleClass="cbStyleClass" onclick="doCheckboxChange(this,'{!c.Dcc.Id}')" />
                </apex:column>
            <apex:column value="{!c.Dcc.Lastname}"/>
            <apex:column value="{!c.Dcc.Firstname}"/>
            <apex:column value="{!c.Dcc.Account.Name}"/>
            <apex:column value="{!c.Dcc.Email}"/>
            <apex:column value="{!c.Dcc.LastModifiedDate}"/>
         </apex:pageBlockTable>
         
       <apex:outputPanel rendered="{! IF(wdlist1!= null && wdlist1.size !=0 , true, false)}">
                <br/>
                <!-- count of selected items -->
                <apex:outputLabel value="Total Number of Records :{!totalSize } " />
            </apex:outputPanel>
              <br/> 
         
          <apex:outputPanel styleClass="center" rendered="{! IF(wdlist1!= null && wdlist1.size !=0 , true, false)}" id="button" >              
                         <apex:commandButton value="First" action="{!beginning}" disabled="{!DisablePrevious}"  />
                         <apex:commandButton value="Previous" action="{!previousP}" disabled="{!DisablePrevious}"    />
                         <apex:commandButton value="Next" action="{!nextP}" disabled="{!DisableNext}"  />
                         <apex:commandButton value="Last" action="{!lastP}" disabled="{!DisableNext}"    />                                 
          </apex:outputPanel>
        <apex:pageBlockButtons rendered="{!wdlist1!=null}"  id="myButtons"  >
          <div style="float:None;align:center;margin-left:20%;"> 
            <apex:actionStatus id="mySaveStatus1">
               <apex:facet name="stop">
                  <apex:commandButton value="Send Mail" action="{!processselected}" style="background:powderblue; width:100px;" reRender="pb2,pb" status="mySaveStatus1"/>
               </apex:facet>
               <apex:facet name="start">
                  <apex:commandButton value="Processing..." status="mySaveStatus1" disabled="true"/>
               </apex:facet>
            </apex:actionStatus> 
           </div>    
         </apex:pageBlockButtons>
         
         
      </apex:pageBlock>
     
   </apex:form>
   
    <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script type="text/javascript">
       
    //function to handle checkbox selection
    function doCheckboxChange(cb,itemId)
    {
        if(cb.selected==true){
            aSelectItem(itemId);
        }
        else{
            aDeselectItem(itemId);
        }        
    }    
    function selectAllCheckboxes(obj){
        $(".cbStyleClass").each(function(index, item){
            item.checked = obj.checked;
        });
        isSelectAllItem(obj.checked);
    }
    
    function updateTextChange(obj, itemId){
        
        updateQuantity(itemId, $(obj).val());
    }
    </script>
   </apex:page>

 
global class mailsend implements Database.Batchable <sobject>, Database.Stateful{

   // global List<string> mailx;
    public id mailid;
    public string mailx;
    public string dumname;
    public string urlcode;
    public List<Contact> Slist;
    public string messageBody;    
    public string queryString = '';
    public set<Id> setIds = new set<Id>();
    
    public mailsend(){}
    
   public mailsend(id DummyconId, string dummymail, string dummyname,   List<Contact>SelectedDc ) {   
       mailid = DummyconId;
       mailx  = dummymail;
       dumname = dummyname;
       this.Slist  = SelectedDc ;
       EmailTemplate templateId = [Select id from EmailTemplate where name = 'Sales: New Customer Email'];   
   }

    global Database.QueryLocator start(Database.Batchablecontext Bc){    
        queryString += ' Where Id IN: setIds ';  
        return Database.getQueryLocator(queryString);
    }

    global void execute(Database.Batchablecontext Bc, List<Dummy_Contact__c> Scope){
            
        Map<id, String> mMap = new Map<id, String>();        
      List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
       For(Dummy_Contact__c dc: Scope){               
         ContactUpdateURL__c mc = ContactUpdateURL__c.getall().values();
         urlcode = mc.URLforContactUpdate__c;       
         String body = '' ;
          //Creating tabular format for the case details
          body = '<html><body>Dear '+dc.name+',<br><br> '+  + 
                                            
                                           'I' + 'm currently updating my contact database and want to make sure I have your current data right.' + +
                                                    
                                           'Could you have a quick look at below info? If you would like to change or update certain information, just click the ' + 'Update Now' + ' link on the bottom of the email and save your changes when done.<br> <br>' + +
                                           
                                            'Last Name:' +dc.name+  '<br><br>' + +
                                            
                                            'Email:' + dc.email__c+ '<br><br>' + +
                                             
                                                                                       
                                            'Title:' +dc.Title__c + '<br><br>'+ +
                                            
                                            'Phone:' +dc.phone__c+ '<br><br>' + +
                                            
                                            'Mobile:' +dc.Mobile_Phone__c+ '<br><br>' + +
                                            
                                            'Fax:' +dc.fax__c+ '<br>' + +
                                            
                                            'Street:' +dc.Mailing_Street__c+ '<br><br>' + +
                                            
                                            'Postalcode:' +dc.Mailing_Zip_Postal_Code__c+ '<br><br>'+ +
                                            
                                            'City:' +dc.Mailing_City__c+ '<br><br>' + +
                                            
                                            'State/Province:' +dc.Mailing_State_Province__c+ '<br><br>' + +
                                            
                                            'Country:' +dc.Mailing_Country__c+ '<br><br>' + +
                                                                                       
                                                                                            
                                            '<a href="'+urlcode+dc.id+'">Update Now</a>' + '<br><br><br>' + +
                                            
                                             'Many thanks in advance, ' +'<br>' + +

                                            
                                           '' + UserInfo.getlastname() +' </html></body>';
        
          Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage() ;
          String[] toAddresses = new String[] {dc.Email__c} ;
          mail.setToAddresses(toAddresses) ;
          mail.setSubject('Touch Contact');
          mail.setHtmlBody(body);
          mails.add(mail);          
        }
        Messaging.sendEmail(mails);
    }
    
    global void finish(Database.Batchablecontext Bc){}
}

 

wanted to count total number of records 

public List<Contact> contactsize = new List<Contact>();
     global void execute(Database.BatchableContext bc,  List<Contact> Scope){
          conupdate = new List<Contact>();
       system.debug('calling update check execute');
    
       For(Contact c: Scope){  
            c.Direct_send__c= true;
              conupdate.add(c);   
           }
       system.debug('contact list' + conupdate.size());  
         contactsize.addAll(conupdate);
         update conupdate;
     }  
    global void finish(Database.BatchableContext bc){
     system.debug('contacts size :' + contactsize.size());
        recordcount = contactsize.size();
I have to send 1 lakh emails in one transaction, for that i used batch, but day limit is 5000, how can i continue that rest of the emails to next day
public class contactSend {
 public set<Id> lstSelectedCons {get;set;}
 public Date dat {
  set;
  get;
 }
 public Date To {
  set;
  get;
 }
 public Boolean showCalendarField {
  get;
  set;
 }
 public Date calendarFieldVal {
  get;
  set;
 }
 public List < Contact > SelectedDc {
  set;
  get;
 }
 public List < WrapDummy > wdlist {
  set;
  get;
 }
 public List < WrapDummy > wdlist1 {
  set;
  get;
 }
 public List < WrapDummy > wdlist2 {
  set;
  get;
 }

 public transient List < Contact > ct {
  set;
  get;
 }
 public string selectedvalue {
  set;
  get;
 }
 public id DummyconId {
  set;
  get;
 }
 public Map < string, id > mMap {
  set;
  get;
 }
 public string dummymail {
  set;
  get;
 }
 public string result {
  set;
  get;
 }
 public String messageBody;
 public Integer totalSize {
  set;
  get;
 }
 public Integer totalPages {
  set;
  get;
 }
 public Set < String > Scon;
 public set < id > setIds;
 public string selectedDataType {
  set;
  get;
 }
 public List < contact > ContactsToShow {
  get;
  set;
 }
 public Integer counter = 0; //TO track the number of records parsed
 public Integer limitSize = 100; //Number of records to be displayed
 //Integer totalSize =0;

 //pagination Standard set
 /**public Apexpages.Standardsetcontroller con;
    
 public Map<Id,Decimal> quantityMap {set;get;}
 public Set<Id> SelectedPropertyIds {set;get;}
 public string ContextItem {set;get;}
 public string ContextItemValue {set;get;} **/
 public Boolean SelectedAllProperties {
  set;
  get;
 }

 //List to show the limited records on the page
 /**  public List<WrapDummy> ContactsToShow {get;set;}
   public List<wrapDummy> currentrecords {get;set;}
   Integer counter = 0;//TO track the number of records parsed
   Integer limitSize = 10;//Number of records to be displayed
   Integer totalSize {set;get;} //To Store the total number of records available

  **/
 public List < Dummy_Contact__c > dummylist {
  set;
  get;
 }

 Public List < Contact > conlist {
  set;
  get;
 }
 public List < Dummy_Contact__c > dclist {
   set;
   get;
  }
  // filter condition variables
 public List < SelectOption > options {
  get;
  set;
 }
 public List < SelectOption > operatorOptions {
  get;
  set;
 }
 public static string selectedOperatorOption {
  get;
  set;
 }
 public static string SelectedOption {
  get;
  set;
 }
 public string enteredText {
  get;
  set;
 }
 public Map < string, string > checkDataTypeMap {
  get;
  set;
 }
 public List < contact > lstContacts {
  get;
  set;
 }
 public transient Map < String, Schema.SObjectType > schemaMap = Schema.getGlobalDescribe();

 public contactSend() {

  options = new List < SelectOption > ();
  checkDataTypeMap = new Map < String, string > ();
  operatorOptions = new List < SelectOption > ();
  //To fetch the Contact fields by Describe call
  Selectoption sv = new SelectOption('--Please Select--', '--Please Select--');
  Options.add(sv);

  Map < String, Schema.SObjectField > ContactFieldsMap = SchemaMap.get('Contact').getDescribe().fields.getMap();
  for (Schema.SObjectField sField: ContactFieldsMap.Values()) {
   schema.describefieldresult fieldName = sfield.getDescribe();
   Schema.DisplayType fielddataType = sfield.getDescribe().getType();
   string fieldType = string.valueOf(fielddataType);
   SelectOption sp = new SelectOption(fieldName.getName(), fieldName.getName());
   checkDataTypeMap.put(fieldName.getName(), fieldType);
   options.add(sp);
   options.sort();
  }  
  //Add the filter conditons feteched from Custom settings to show in picklist
  SelectOption selOpt = new SelectOption('--Please Select--', '--Please Select--');
  operatorOptions.add(selOpt);

  List < CustomCondition1__c > filetConditions = CustomCondition1__c.getall().values();
  for (CustomCondition1__c Fcon: filetConditions) {
   SelectOption Fsp = new SelectOption(Fcon.Name, Fcon.Name);
   operatorOptions.add(Fsp);
   operatorOptions.sort();
  }
 }

 public PageReference createcon() {

  conlist = [SELECT id, LastName, AssistantName, AssistantPhone, Birthdate, Department, Description, Email, Fax, HomePhone, MailingAddress,
   MailingCity, MailingCountry, MailingPostalCode, MailingState, MailingStreet, MobilePhone, Name, OtherAddress, OtherCity,
   OtherCountry, OtherPhone, OtherPostalCode, OtherState, OtherStreet, Phone, Title,
       (SELECT id, email__c, Assistant_Name__c, Assistant_Phone__c, Birthdate__c, Contact__c,
        Department__c, Description__c, Fax__c, First_Name__c, Home_Phone__c, Mailing_City__c, Mailing_Country__c,
        Mailing_State_Province__c, Mailing_Street__c, Mailing_Zip_Postal_Code__c, Mobile_Phone__c,
        Other_City__c, Other_Country__c, Other_Phone__c, Other_State_Province__c, Other_Street__c,
        Other_Zip_Postal_Code__c, Phone__c, Title__c from Cons__r)
   From Contact where id in :lstSelectedCons limit 9999 
  ];

  list < Dummy_Contact__c > listDummyContactMain = new list < Dummy_Contact__c > ();
  list < Dummy_Contact__c > listDummyContactNew = new list < Dummy_Contact__c > ();

  for (Contact c: conlist) {
   if (c.Cons__r.size() == 0) {

    Dummy_Contact__c Dcobj = new Dummy_Contact__c();
    Dcobj.Name = c.LastName;
    Dcobj.Assistant_Name__c = c.AssistantName;
    Dcobj.Assistant_Phone__c = c.AssistantPhone;
    Dcobj.Birthdate__c = c.Birthdate;
    Dcobj.Description__c = c.Description;
    Dcobj.Department__c = c.Department;      
    Dcobj.Email__c = c.Email;
    Dcobj.Fax__c = c.Fax;
    Dcobj.Mailing_City__c = c.MailingCity;
    Dcobj.Mailing_Country__c = c.MailingCountry;
    Dcobj.Mailing_Zip_Postal_Code__c = c.MailingPostalCode;
    Dcobj.Mailing_State_Province__c = c.MailingState;
    Dcobj.Mailing_Street__c = c.MailingStreet;
    Dcobj.Other_City__c = c.OtherCity;
    Dcobj.Other_Country__c = c.OtherCountry;
    Dcobj.Other_Phone__c = c.OtherPhone;
    Dcobj.Other_Zip_Postal_Code__c = c.OtherPostalCode;
    Dcobj.Other_State_Province__c = c.OtherState;
    Dcobj.Other_Street__c = c.OtherStreet;
    Dcobj.Phone__c = c.Phone;
    Dcobj.Home_Phone__c = c.HomePhone;
    Dcobj.Mobile_Phone__c = c.MobilePhone;
    Dcobj.Title__c = c.Title;
    Dcobj.Contact__c = c.id;

    listDummyContactNew.add(Dcobj);

    //insert Dcobj;

   } else {
    listDummyContactMain.add(c.Cons__r[0]);
   }
  }
  if (!listDummyContactNew.isEmpty())
  try{
   insert listDummyContactNew;
   }
   catch(Exception e){
   system.debug(e.getMessage());
   }
  setIds = new set < id > ();
  listDummyContactMain.addAll(listDummyContactNew);

  for (Dummy_Contact__c dummy: listDummyContactMain) {
   String ids = '';
   ids += '\'';
   ids += String.valueOf(dummy.id);
   ids += '\'';
   //setIds.add(ids);
   setIds.add(dummy.id);
  }

  return null;
 }

 public pageReference getTeamMembers() {
  getslist();
  return null;
 }

 public List < SelectOption > getslist() {
  List < SelectOption > Slist = new List < SelectOption > ();
  Slist.add(new SelectOption('Not Contacted', 'Not Contacted'));
  Slist.add(new SelectOption('Contacted', 'Contacted'));
  Slist.add(new SelectOption('30 days', '30 days'));
  Slist.add(new SelectOption('60 days', '60 days'));
  Slist.add(new SelectOption('90 days', '90 days'));

  return Slist;
 }

 public pageReference Search() {
  ct = new List < contact > ();
  result = null;
  Date lastDate30 = System.today().addDays(-30);
  Date lastDate60 = System.today().addDays(-60);
  Date lastDate90 = System.today().addDays(-90);
  wdlist = new List < WrapDummy > ();
  wdlist1 = new List < WrapDummy > ();
  wdlist2 = new List < WrapDummy > ();

  string soql = 'SELECT id,LastName,AssistantName,AssistantPhone,Birthdate,Department,Description,Email,Fax,' + +
   'HomePhone,MailingAddress,MailingCity,MailingCountry,MailingPostalCode,MailingState,' + +
   'MailingStreet,MobilePhone,Name,firstname,OtherAddress,OtherCity,OtherCountry,OtherPhone,OtherPostalCode,' + +
   'OtherState,OtherStreet,Account.Name,LastModifiedDate,Phone,Title,Mail_Sent_Date__c,' + +
   '(SELECT Assistant_Name__c,Assistant_Phone__c,Birthdate__c,Contact__c,CreatedById,CreatedDate,Department__c,Description__c,Email__c,Fax__c,First_Name__c,Home_Phone__c,Id,IsDeleted,Mailing_City__c,Mailing_Country__c,Mailing_State_Province__c,Mailing_Street__c,Mailing_Zip_Postal_Code__c,Mobile_Phone__c,Name,Other_City__c,Other_Country__c,Other_Phone__c,Other_State_Province__c,Other_Street__c,Other_Zip_Postal_Code__c,OwnerId,Phone__c,Title__c from Cons__r) From Contact where   ';
  string whereConditions = '';

  string resultQuery = '';
  if (string.isNotBlank(SelectedOption)) {
   whereConditions = SelectedOption;
  }
  if (string.isNotBlank(selectedOperatorOption)) {
   if (selectedOperatorOption == 'Equal to') {
    selectedOperatorOption = '=';
   } else {
    if (selectedOperatorOption == 'Not equal to') {
     selectedOperatorOption = '!=';
    }
   }
   whereConditions = whereConditions + ' ' + selectedOperatorOption;
   system.debug('enteredText ************ ' + enteredText);
   if (string.isNotBlank(enteredText) || calendarFieldVal != null) {
    string selectedDataType = checkDataTypeMap.get(SelectedOption);
    if (selectedDataType == 'BOOLEAN') {
     whereConditions = whereConditions + ' ' + enteredText;
    }
    if (selectedDataType == 'STRING')
     whereConditions = whereConditions + ' ' + '\'' + enteredText + '\'';
    if (selectedDataType == 'DATE') {
     whereConditions = whereConditions + ' ' + calendarFieldVal;
    }
   }
   if (selectedvalue == 'Not Contacted') {
    if (selectedOperatorOption == 'Select Value' || enteredText == '') {
     resultQuery = soql + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c = null';
        system.debug('hello1 :'+resultQuery);
    } else {
     resultQuery = soql + whereConditions + ' AND  ' + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c = null';
        system.debug('hello2 :'+resultQuery);
    }
    ct = database.query(resultQuery + ' Limit 10000');
       system.debug('ct sixe is1  :'+ct);
   }
  }
  if (selectedvalue == 'Contacted') {
   if (selectedOperatorOption == '--Please Select--' || enteredText == '') {
    resultQuery = soql + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c != null';

   } else {
    resultQuery = soql + whereConditions + ' AND  ' + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c != null';
   }
   ct = database.query(resultQuery + ' Limit 10000');
      system.debug('ct sixe is2  :'+ct);
  } else if (selectedvalue == '30 days') {
   if (selectedOperatorOption == 'Select Value' || enteredText == '') {
    resultQuery = soql + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate30';

   } else {
    resultQuery = soql + whereConditions + ' AND  ' + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate30';
   }
   ct = database.query(resultQuery + ' Limit 10000');
      system.debug('ct sixe is3  :'+ct);
  } else if (selectedvalue == '60 days') {
   if (selectedOperatorOption == 'Select Value' || enteredText == '') {
    resultQuery = soql + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate60';

   } else {
    resultQuery = soql + whereConditions + ' AND  ' + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate60';
   }
   ct = database.query(resultQuery + ' Limit 10000');
    system.debug('ct sixe is4  :'+ct);
  } else if (selectedvalue == '90 days')
  {
       if (selectedOperatorOption == 'Select Value' || enteredText == '') {
        resultQuery = soql + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate90';
    
       } else {
        resultQuery = soql + whereConditions + ' AND  ' + 'LastModifiedDate >=:dat AND LastModifiedDate <=:to and Mail_Sent_Date__c < :lastDate90';
       }
       ct = database.query(resultQuery + ' Limit 10000');
        system.debug('ct sixe is5  :'+ct);
  }

  dummylist = new List < Dummy_Contact__c > ();
  if (!ct.isEmpty()) {
   for (Contact cf: ct) {       
    for (Dummy_Contact__c df: cf.Cons__r) {
     DummyconId = df.id;
     dummymail = df.email__c;
     dummylist.add(df);
    }
   }   
  }
     for (Contact dt: ct)
        wdlist.add(new WrapDummy(dt));
  totalSize = wdlist.size();
     system.debug('total size is :'+totalSize);
  if ((counter + limitSize) <= totalSize) {
   for (Integer i = 0; i < limitSize; i++) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  } else {
   for (Integer i = 0; i < totalSize; i++) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  }

  totalPages = Integer.valueOf(Math.ceil(totalSize / (Double) limitSize));
  return null;
 }

 public void beginning() {
system.debug('wdlist is :'+wdlist);
 
  wdlist1.clear();
  counter=0;
  if ((counter + limitSize) <= totalSize) {      
   for (Integer i = 0; i < limitSize; i++) {
       if(!wdlist.isEmpty()){
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
       }
   }
  } else {
   for (Integer i = 0; i < totalSize; i++) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  }
 }
 public void nextP() {


  if (selectedAllProperties)
   selectedAllProperties = true;


  else
   selectedAllProperties = false;

  wdlist1.clear();
  counter = counter + limitSize;

  if ((counter + limitSize) <= totalSize) {
   for (Integer i = counter; i < (counter + limitSize); i++) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  } else {
   for (Integer i = counter; i < totalSize; i++) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  }

 }
 public void previousP() {
  if (selectedAllProperties)
   selectedAllProperties = true;

  else
   selectedAllProperties = false;


  wdlist1.clear();
  counter = counter - limitSize;
  for (Integer i = counter; i < (counter + limitSize); i++) {
   if (!wdlist.isEmpty()) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  }

 }
 public void lastP() {

system.debug('wdlist is :'+wdlist);
  wdlist1.clear();
  if (math.mod(totalSize, limitSize) == 0)
   counter = limitSize * ((totalSize / limitSize) - 1);
  else if (math.mod(totalSize, limitSize) != 0)
   counter = limitSize * ((totalSize / limitSize));
system.debug('counter :'+counter);
     system.debug('totalSize :'+totalSize);
  for (Integer i = counter - 1; i < totalSize - 1; i++) {
   if (!wdlist.isEmpty()) {
    wdlist1.add(wdlist.get(i));
    wdlist2.add(wdlist.get(i));
   }
  }
 }
 public Boolean getDisableNext() {

  if ((counter + limitSize) >= totalSize)
   return true;
  else
   return false;
 }

 public Boolean getDisablePrevious() {

  if (counter == 0)
   return true;
  else
   return false;
 }
 public PageReference processselected() {
  Set < String > scon = new Set < String > ();
  lstSelectedCons = new set<Id>();
  SelectedDc = new List < Contact > ();
  set < Contact > ncts = new set < Contact > ();

  List < contact > updatecons = new List < Contact > ();
  if (!wdlist2.isEmpty()) {
   for (WrapDummy WrapDummyobj: wdlist2) {
    if (WrapDummyobj.selected == true) {
        lstSelectedCons.add(WrapDummyobj.Dcc.Id);
     SelectedDc.add(WrapDummyobj.Dcc);
     
     for (contact cts: SelectedDc) {
      cts.Mail_Sent_Date__c = Date.today();
      ncts.add(cts);
      // setids.add(cts.id);
    
     }
     //update ncts;                   
    }
   }

   if (!ncts.isEmpty()) {
    list < Contact > listNcts = new list < Contact > ();
    listNcts.addAll(ncts);
   }
   createcon();
  }
 // EmailTemplate templateId = [Select id from EmailTemplate where name = 'Sales: New Customer Email'];
  ContactUpdateURL__c mc = ContactUpdateURL__c.getall().values();
  string urlcode = mc.URLforContactUpdate__c;
  Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();

  if (SelectedDc.size() > 9) {
   for (contact c: SelectedDc) {
    scon.add(String.valueOf(c.id));
    system.debug(c.id);
    system.debug(c.cons__r);
     
    string cEmail = c.Email;
  
   }

   mailsend objmailsend = new mailsend();
   objmailsend.setIds = setIds;
   objmailsend.queryString = 'Select Assistant_Name__c,Assistant_Phone__c,Birthdate__c,Contact__c,CreatedById,CreatedDate,Department__c,Description__c,Email__c,Fax__c,First_Name__c,Home_Phone__c,Id,IsDeleted,Mailing_City__c,Mailing_Country__c,Mailing_State_Province__c,Mailing_Street__c,Mailing_Zip_Postal_Code__c,Mobile_Phone__c,Name,Other_City__c,Other_Country__c,Other_Phone__c,Other_State_Province__c,Other_Street__c,Other_Zip_Postal_Code__c,OwnerId,Phone__c,Title__c   From Dummy_Contact__c';

   Database.executeBatch(objmailsend);
   result = 'Sending Emails are under process';
   for (Contact cs: SelectedDc) {
    cs.Mail_Sent_Date__c = Date.today();
    updatecons.add(cs);
   }


  } else {
  system.debug('Email to send contact is : '+SelectedDc);
   for (contact c: SelectedDc) {

    scon.add(String.valueOf(c.id));
    string cEmail = c.Email;
       system.debug('be fore dummt contatc is : '+cEmail);
    for (Dummy_Contact__c dd: c.cons__r) {
        system.debug('dummt contatc is : '+dd);
     id DummyconId = dd.id;
     string dummyname = dd.name;
     string dummymail = dd.email__c;
     string dummytitle = dd.Title__c;
     string dummyphone = dd.phone__c;
     string dummymobile = dd.Mobile_Phone__c;
     string dummyfax = dd.fax__c;
     string dummymailingstreet = dd.Mailing_Street__c;
     string dummypostalcode = dd.Mailing_Zip_Postal_Code__c;
     string dummymailingcity = dd.Mailing_City__c;
     string dummystate = dd.Mailing_State_Province__c;
     string dummycountry = dd.Mailing_Country__c;
      
     
        
     message.toAddresses = new String[] {
      dummymail
     };
     
     message.setTargetObjectId(c.id);
     message.optOutPolicy = 'FILTER';
     message.subject = 'Touch Contact';
     messageBody = '<html><body>Dear ' + dummyname + ',<br><br> ' + +

      'I' + 'm currently updating my contact database and want to make sure I have your current data right.' + +

      'Could you have a quick look at below info? If you would like to change or update certain information, just click the ' + 'Update Now' + ' link on the bottom of the email and save your changes when done.<br> <br>' + +

      'Last Name:' + dummyname + '<br><br>' + +

      'Email:' + dummymail + '<br><br>' + +

      'Current company:' + +'<br><br>' + +

      'Title:' + dummytitle + '<br><br>' + +

      'Phone:' + dummyphone + '<br> <br>' + +

      'Mobile:' + dummymobile + '<br><br>' + +

      'Fax:' + dummyfax + '<br><br>' + +

      'Street:' + dummymailingstreet + '<br><br>' + +

      'Postalcode:' + dummypostalcode + '<br><br>' + +

      'City:' + dummymailingcity + '<br><br>' + +

      'State/Province:' + dummystate + '<br><br>' + +

      'Country:' + dummycountry + '<br><br><br>' + +

      '<a href="' + urlcode + DummyconId + '">Update Now</a>' + '<br><br><br>' + +

      'Many thanks in advance, ' + '<br>' + +


      '' + UserInfo.getlastname() + ' </html></body>';


     message.setHtmlBody(messageBody);
     message.setSaveAsActivity(false);
     Messaging.SingleEmailMessage[] messages = new List < Messaging.SingleEmailMessage > {
      message
     };
     Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
  system.debug('hello email :'+results);
     if (results[0].success) {
      c.Mail_Sent_Date__c = Date.today();
      updatecons.add(c);
      result = 'Email Sent';
     } else {
      string result = 'Email Not Sent';
     }
     break;
    }
   }

  }
  if(!updatecons.isEmpty())
  update updatecons;
  if (SelectedDc.isEmpty()) {
   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Please Select value'));
   return null;
  }

  pageReference pr = new PageReference('/apex/ContactMassMail1');
  pr.setRedirect(true);
  return pr;
 }

 public class WrapDummy {
  public Contact Dcc {
   set;
   get;
  }
  public Boolean selected {
   set;
   get;
  }
  public Decimal quantity {
   set;
   get;
  }
  public WrapDummy(Contact dt) {
   Dcc = dt;
   selected = false;
   quantity = 0;
  }
 }
 public pageReference enableCalendarTextBox() {
  string selDataType = checkDataTypeMap.get(SelectedOption);
  if (selDataType == 'DATE') {
   showCalendarField = true;
  } else {
   showCalendarField = false;
  }
  return null;
 }
}
=====================vf ==================
<apex:page showHeader="true" sidebar="false" controller="contactSend"  docType="html-5.0" id="mypage"  tabStyle="Contact" >
   <style type = "text/css">
      .pbs{
      color: red;
      }
   </style>
        
   <apex:form id="fm"  style="color:blue;">
      <apex:pageBlock id="pb" >
         <apex:pageMessages ></apex:pageMessages>
         <apex:pageBlockSection collapsible="false" id="pbs" >
            <apex:outputLabel >Last Modified Date From</apex:outputLabel>
            <apex:input type="date" value="{!dat}"    />
            <apex:outputLabel >Last Modified Date To</apex:outputLabel>
            <apex:input type="date"  value="{!to}"  />
            <apex:outputLabel >Contact Last sent</apex:outputLabel>
            <apex:selectList value="{!selectedvalue}" multiselect="false" size="1">
               <apex:selectOptions value="{!Slist}"></apex:selectOptions>
            </apex:selectList>
         </apex:pageBlockSection>
         <apex:pageBlock id="filt">
            <apex:outputLabel value="Select Field"  />
            :   
            <apex:selectList value="{!SelectedOption}" size="1">
                <apex:selectOptions value="{!Options}"  />
                  <apex:actionSupport event="onchange"  action="{!enableCalendarTextBox}" reRender="calendarField"   />              
            </apex:selectList>
            <apex:selectList value="{!selectedOperatorOption}" size="1" >
               <apex:selectOptions value="{!operatorOptions}" >                  
               </apex:selectOptions>
            </apex:selectList>   
             
            <apex:outputPanel id="calendarField">                
               <apex:input type="date" value="{!calendarFieldVal}"  style="{!if(showCalendarField,'display:hidden;', 'display:none')}"   />
                <apex:inputText value="{!enteredText}" style="{!if(showCalendarField,'display:none;', 'display:hidden')}" />                
            </apex:outputPanel>            
         </apex:pageBlock>
         <div class="pbs"  >
            <apex:pageBlockButtons location="bottom" > 
               <div style="float:None;align:center;margin-left:20%;"> 
               <apex:commandButton value="Search" action="{!Search}" status="actStatusId1" style="background:powderblue; width:100px;" rerender="table1, pb2,fm,pb,pi">
                  <apex:actionsupport event="oncomplete" rerender=" pb1"/>
               </apex:commandButton>
               </div>
            </apex:pageBlockButtons>
         </div>
      </apex:pageBlock>
      <apex:pageBlock id="pb1" >
         <apex:actionStatus id="actStatusId1" startText=" Processing the stuff "  >
            <apex:facet name="start" >
               <img src="/img/loading.gif" />
            </apex:facet>
         </apex:actionStatus>
         
      
          
        <apex:pageBlock title="Contact Details" id="noRec" rendered="{! IF(wdlist1!= null && wdlist1.size ==0 , true, false)}" >
            <apex:outputPanel >
                <h1>No Records Found </h1>
            </apex:outputPanel>
            </apex:pageBlock>
               <apex:pageBlockTable value="{!wdlist1}" var="c" id="table1"   > 
            <apex:column >
                    <apex:facet name="header">
                        <apex:inputCheckbox value="{!selectedAllProperties}" onclick="selectAllCheckboxes(this)" rendered="{! IF(wdlist1!= null && wdlist1.size !=0 , true, false)}" />
                    </apex:facet> 
                    <apex:inputCheckbox value="{!c.selected}" styleClass="cbStyleClass" onclick="doCheckboxChange(this,'{!c.Dcc.Id}')" />
                </apex:column>
            <apex:column value="{!c.Dcc.Lastname}"/>
            <apex:column value="{!c.Dcc.Firstname}"/>
            <apex:column value="{!c.Dcc.Account.Name}"/>
            <apex:column value="{!c.Dcc.Email}"/>
            <apex:column value="{!c.Dcc.LastModifiedDate}"/>
         </apex:pageBlockTable>
         
       <apex:outputPanel rendered="{! IF(wdlist1!= null && wdlist1.size !=0 , true, false)}">
                <br/>
                <!-- count of selected items -->
                <apex:outputLabel value="Total Number of Records :{!totalSize } " />
            </apex:outputPanel>
              <br/> 
         
          <apex:outputPanel styleClass="center" rendered="{! IF(wdlist1!= null && wdlist1.size !=0 , true, false)}" id="button" >              
                         <apex:commandButton value="First" action="{!beginning}" disabled="{!DisablePrevious}"  />
                         <apex:commandButton value="Previous" action="{!previousP}" disabled="{!DisablePrevious}"    />
                         <apex:commandButton value="Next" action="{!nextP}" disabled="{!DisableNext}"  />
                         <apex:commandButton value="Last" action="{!lastP}" disabled="{!DisableNext}"    />                                 
          </apex:outputPanel>
        <apex:pageBlockButtons rendered="{!wdlist1!=null}"  id="myButtons"  >
          <div style="float:None;align:center;margin-left:20%;"> 
            <apex:actionStatus id="mySaveStatus1">
               <apex:facet name="stop">
                  <apex:commandButton value="Send Mail" action="{!processselected}" style="background:powderblue; width:100px;" reRender="pb2,pb" status="mySaveStatus1"/>
               </apex:facet>
               <apex:facet name="start">
                  <apex:commandButton value="Processing..." status="mySaveStatus1" disabled="true"/>
               </apex:facet>
            </apex:actionStatus> 
           </div>    
         </apex:pageBlockButtons>
         
         
      </apex:pageBlock>
     
   </apex:form>
   
    <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script type="text/javascript">
       
    //function to handle checkbox selection
    function doCheckboxChange(cb,itemId)
    {
        if(cb.selected==true){
            aSelectItem(itemId);
        }
        else{
            aDeselectItem(itemId);
        }        
    }    
    function selectAllCheckboxes(obj){
        $(".cbStyleClass").each(function(index, item){
            item.checked = obj.checked;
        });
        isSelectAllItem(obj.checked);
    }
    
    function updateTextChange(obj, itemId){
        
        updateQuantity(itemId, $(obj).val());
    }
    </script>
   </apex:page>