function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gopal ChatGopal Chat 

Page is not working

In my page after selecting sendEmail Button,My page is redirecting to EmailDetail page
But In EmailDetail page selected contact is not showing.
Here is code
<apex:page controller="SearchRecords"  showHeader="false" sidebar="false" >
    <apex:form id="frm">
        <apex:pageblock >
            <apex:pageBlockSection title="Search Account Records" columns="1">
                Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
                <apex:commandButton action="{!searchRecord}" value="Search" id="theSearch" reRender="frm"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Account Detail" id="pb">
                <apex:pageBlocktable value="{!accountlist}" var="acc">
                    <apex:column >
                        <input type="radio" name="group1" reRender="{!display}" />
                        <apex:actionSupport event="onclick" action="{!newClick}" reRender="conSection"  >
                            <apex:param assignTo="{!AccId}" name="accname" value="{!acc.id}"/>
                        </apex:actionSupport>
                    </apex:column>
                    <apex:column value="{!acc.Name}"/>
                    <apex:column value="{!acc.Phone}"/>
                </apex:pageBlocktable>
            </apex:pageBlockSection>
            
            <apex:outputPanel id="conSection">
                <apex:pageBlockSection title="Related Contact" id="conpgblk" rendered="{!display}" >
                    <apex:outputPanel rendered="{!listWrapper.size != 0}">
                        <div align="center" >
                            <apex:commandButton value="Send Email" action="{!SendEmail}"/>
                            <apex:commandButton value="Print Detail" action="{!PrintDetail}"/>
                        </div>
                        <apex:pageBlockTable value="{!listWrapper}" id="pbt1" var="wrap">
                            <apex:column headerValue="Select">
                            <apex:inputCheckbox value="{!wrap.checked}" id="inputBox"/>
                            </apex:column>
                            <apex:column value="{!wrap.con.Name}"/>
                            <apex:column value="{!wrap.con.Phone}"/>
                            <apex:column value="{!wrap.con.Email}"/>
                            <apex:column value="{!wrap.con.Account.Name}"/>
                            <apex:column value="{!wrap.con.AccountId}"/>
                            <apex:column value="{!wrap.con.Id}"/>
                        </apex:pageBlockTable>
                    <apex:commandButton value="First Page" rerender="conpgblk" action="{!FirstPage}" disabled="{!prev}"/>
                    <apex:commandButton value="Previous" rerender="conpgblk" action="{!previous}" disabled="{!prev}"/>
                    <apex:commandButton value="Next" rerender="conpgblk" action="{!next}" disabled=""/>
                    <apex:commandButton value="Last Page" rerender="conpgblk" action="{!LastPage}" disabled="{!disable}"/> 
                    </apex:outputPanel>
                    <apex:outputPanel rendered="{!listWrapper.size == 0}">
                        <b> NO RELATED CONTACTS FOR THIS ACCOUNT.</b> 
                    </apex:outputPanel>
                </apex:pageBlockSection>
            </apex:outputPanel>
        </apex:pageblock>
    </apex:form>
</apex:page>

public class SearchRecords {
    public boolean display{get;set;}
    public boolean disable{get;set;}
    public String AccId{get;set;}
    public string getstring{get;set;}
    public string selectedvalie{get;set;}
    public List<Account> accountlist {get;set;}
    public list<Contact> conList{get;set;}
    public list<Attachment> AttachmentList{get;set;}
    private integer totalRecs = 0;
    private integer OffsetSize = 0;
    private integer LimitSize=3;
    public  contact con{get;set;}
    public  Attachment Att{get;set;}
    public  string Body{get;set;}
    public string Subject{get;set;}
    public string selectAttachment{get;set;}
    public boolean Attc{get;set;}
    public boolean Docu{get;set;}
    public boolean SysFil{get;set;}
    public List<WrapperClass> listWrapper {get;set;}
    public List<WrapperClass> listWrapper1 {get;set;}
    public void searchRecord(){
        display=False;
        accountlist= new list<Account>();
        if(getstring!=null){
            accountlist= Database.query('select id,AccountNumber,name,Phone from Account where name like \'%'+getstring+'%\'');
        }
    } 
    public void newClick(){
        disable=false;
        LimitSize=3;
        OffsetSize=0;
        showContact();
    }
    public void showContact(){
        display=true;
        listWrapper = new List<WrapperClass>();
        List<Contact> conlist =[SELECT id,Title,Fax,Birthdate,Name,Account.Name,Phone,Email FROM Contact WHERE AccountId=:AccId LIMIT :LimitSize OFFSET :OffsetSize];
        if(conlist!=NULL){
            totalRecs = conlist.size();
            for(contact con:conlist)
            {
                listWrapper.add(new WrapperClass(con));
            }
        }
    }
    public pageReference PrintDetail(){
        listWrapper1=new list<WrapperClass>();
        for(WrapperClass wr: listWrapper){
            if(wr.checked==true)
                listWrapper1.add(wr);
        }
        pageReference acctPage = new pageReference('/Apex/printContactDetail');
        return acctPage;
    }
 
    public pageReference SendEmail(){
        listWrapper1=new list<WrapperClass>();
          String str='';
        for(WrapperClass wr: listWrapper){
            if(wr.checked==true){
                listWrapper1.add(wr);
            str+=wr.con.id+',';
            }
            system.debug('====>listWrapper1'+listWrapper1);
        }
        str=str.removeEnd(',');
        pageReference EmailPage = new pageReference('/Apex/EmailDetail?id='+str);
        emailPage.setRedirect(true);
            return EmailPage;
    }
    public pageReference AddFile(){
        String str=ApexPages.currentPage().getParameters().get('id');
        PageReference acctPage = new pageReference('/Apex/AttachmentPage?id='+str);
        return acctPage;
    }
    set<id> contactId=new set<Id>();
    
    public void Attachment(){
       String str1=ApexPages.currentPage().getParameters().get('id');
        system.debug('---line81'+str1);
        for(string st:str1.split(',')){
            contactid.add(st);
        }
       AttachmentList=[select Id,Name,Body,BodyLength,ContentType,ParentId from Attachment where ParentId IN:contactId];
        system.debug('AttachmentList'+AttachmentList);
    }
    public void HideShow(){
        system.debug('selectAttachment'+selectAttachment);
        if(selectAttachment=='Attachment'){
            Attc=True;
            Docu=False;
            SysFil=False;
            Attachment();
        }
        else if(selectAttachment=='Document'){
            Attc=False;
            Docu=True;
            SysFil=False;
        }
        else if(selectAttachment=='System File'){
            Attc=False;
            Docu=False;
            SysFil=True;
        }
    }
    public pageReference Send(){
        return null;
    }
    public pageReference Cancel(){
        return null;
    }
    public void FirstPage(){
        disable=false;
        OffsetSize = 0;
        showContact();
    }
    public void previous(){
        disable=false;
        OffsetSize = OffsetSize - LimitSize;
        showContact();
    }
    public void next(){
        OffsetSize = OffsetSize + LimitSize;
        showContact();
    }
    public void LastPage(){
        disable=true;
        OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
        showContact();
        
    }
    public boolean getprev(){
        if(OffsetSize == 0)
            return true;
        else
            return false;
        
    }
    public boolean getnxt(){
        if((OffsetSize + LimitSize) > totalRecs)
            return true;
        else
            return false;
    }

    public pageReference Save(){
            return null;
        }
    public class WrapperClass {
        public Boolean checked {get;set;}
        public contact con {get;set;}
        public WrapperClass(contact con) {
            this.con=con;
            checked=false;
        }
    }
}
EmailDetail page
<apex:page controller="SearchRecords" showHeader="false" sidebar="false">
    <script>
        function openPopup(){
             window.open('/apex/AttachmentPage','mywindow','width=600,height=400');
        }    
    </script>
    <apex:form >
        <apex:pageBlock title="Send Email To Selected Contacts">
            <div align="Middle">
                <apex:commandButton value="Send" action="{!Send}" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:commandButton value="Add File" onclick="openPopup();return false;"/> &nbsp;&nbsp;&nbsp;&nbsp;
                <apex:commandButton value="Cancel" action="{!Cancel}"/>&nbsp;&nbsp;&nbsp;&nbsp;
            </div>
            <apex:pageBlockSection title="Email" columns="1">
                <apex:repeat value="{!listWrapper1}" var="wrap">
                    To:<apex:outputfield value="{!wrap.con.Name}" />
                </apex:repeat>
                <div class = "requiredInput">
                    Subject<div class = "requiredBlock"></div>
                    <apex:inputText title="Subject" required="true"/>
                </div>
                <apex:inputtextarea label="Body" richtext="true" value="{!Body}" cols="50" rows="15"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Best Answer chosen by Gopal Chat
Sohan Raj GuptaSohan Raj Gupta
Hi Raghav,

You can use below code:
 
public class SearchRecords {
    public boolean display{get;set;}
    public boolean disable{get;set;}
    public String AccId{get;set;}
    public string getstring{get;set;}
    public string selectedvalie{get;set;}
    public List<Account> accountlist {get;set;}
    public list<Contact> conList{get;set;}
    public list<Attachment> AttachmentList{get;set;}
    private integer totalRecs = 0;
    private integer OffsetSize = 0;
    private integer LimitSize=3;
    public  contact con{get;set;}
    public  Attachment Att{get;set;}
    public  string Body{get;set;}
    public string Subject{get;set;}
    public string selectAttachment{get;set;}
    public boolean Attc{get;set;}
    public boolean Docu{get;set;}
    public boolean SysFil{get;set;}
    public List<WrapperClass> listWrapper {get;set;}
    public List<WrapperClass> listWrapper1 {get;set;}
    public void searchRecord(){
        display=False;
        accountlist= new list<Account>();
        if(getstring!=null){
            accountlist= Database.query('select id,AccountNumber,name,Phone from Account where name like \'%'+getstring+'%\'');
        }
    } 
    public void newClick(){
        disable=false;
        LimitSize=3;
        OffsetSize=0;
        showContact();
    }
    public void showContact(){
        display=true;
        listWrapper = new List<WrapperClass>();
        List<Contact> conlist =[SELECT id,Title,Fax,Birthdate,Name,Account.Name,Phone,Email FROM Contact WHERE AccountId=:AccId LIMIT :LimitSize OFFSET :OffsetSize];
        if(conlist!=NULL){
            totalRecs = conlist.size();
            for(contact con:conlist)
            {
                listWrapper.add(new WrapperClass(con));
            }
        }
    }
    
    public void showContact1(){
        string id = ApexPages.currentPage().getParameters().get('id');
        string[] ids = id.split(',');
        
        display=true;
        listWrapper1 = new List<WrapperClass>();
        List<Contact> conlist =[SELECT id,Title,Fax,Birthdate,Name,Account.Name,Phone,Email FROM Contact WHERE ID IN :ids LIMIT :LimitSize OFFSET :OffsetSize];
        if(conlist!=NULL){
            totalRecs = conlist.size();
            for(contact con:conlist)
            {
                listWrapper1.add(new WrapperClass(con));
            }
        }
        
    }
    
    
    public pageReference PrintDetail(){
        listWrapper1=new list<WrapperClass>();
        for(WrapperClass wr: listWrapper){
            if(wr.checked==true)
                listWrapper1.add(wr);
        }
        pageReference acctPage = new pageReference('/Apex/printContactDetail');
        return acctPage;
    }
 
    public pageReference SendEmail(){
        listWrapper1=new list<WrapperClass>();
          String str='';
        for(WrapperClass wr: listWrapper){
            if(wr.checked==true){
                listWrapper1.add(wr);
            str+=wr.con.id+',';
            }
            system.debug('====>listWrapper1'+listWrapper1);
        }
        str=str.removeEnd(',');
        pageReference EmailPage = new pageReference('/Apex/EmailDetail?id='+str);
        emailPage.setRedirect(true);
            return EmailPage;
    }
    public pageReference AddFile(){
        String str=ApexPages.currentPage().getParameters().get('id');
        PageReference acctPage = new pageReference('/Apex/AttachmentPage?id='+str);
        return acctPage;
    }
    set<id> contactId=new set<Id>();
    
    public void Attachment(){
       String str1=ApexPages.currentPage().getParameters().get('id');
        system.debug('---line81'+str1);
        for(string st:str1.split(',')){
            contactid.add(st);
        }
       AttachmentList=[select Id,Name,Body,BodyLength,ContentType,ParentId from Attachment where ParentId IN:contactId];
        system.debug('AttachmentList'+AttachmentList);
    }
    public void HideShow(){
        system.debug('selectAttachment'+selectAttachment);
        if(selectAttachment=='Attachment'){
            Attc=True;
            Docu=False;
            SysFil=False;
            Attachment();
        }
        else if(selectAttachment=='Document'){
            Attc=False;
            Docu=True;
            SysFil=False;
        }
        else if(selectAttachment=='System File'){
            Attc=False;
            Docu=False;
            SysFil=True;
        }
    }
    public pageReference Send(){
        return null;
    }
    public pageReference Cancel(){
        return null;
    }
    public void FirstPage(){
        disable=false;
        OffsetSize = 0;
        showContact();
    }
    public void previous(){
        disable=false;
        OffsetSize = OffsetSize - LimitSize;
        showContact();
    }
    public void next(){
        OffsetSize = OffsetSize + LimitSize;
        showContact();
    }
    public void LastPage(){
        disable=true;
        OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
        showContact();
        
    }
    public boolean getprev(){
        if(OffsetSize == 0)
            return true;
        else
            return false;
        
    }
    public boolean getnxt(){
        if((OffsetSize + LimitSize) > totalRecs)
            return true;
        else
            return false;
    }

    public pageReference Save(){
            return null;
        }
    public class WrapperClass {
        public Boolean checked {get;set;}
        public contact con {get;set;}
        public WrapperClass(contact con) {
            this.con=con;
            checked=false;
        }
    }
}
 
<apex:page controller="SearchRecords"  showHeader="false" sidebar="false" >
    <apex:form id="frm">
        <apex:pageblock >
            <apex:pageBlockSection title="Search Account Records" columns="1">
                Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
                <apex:commandButton action="{!searchRecord}" value="Search" id="theSearch" reRender="frm"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Account Detail" id="pb">
                <apex:pageBlocktable value="{!accountlist}" var="acc">
                    <apex:column >
                        <input type="radio" name="group1" reRender="{!display}" />
                        <apex:actionSupport event="onclick" action="{!newClick}" reRender="conSection"  >
                            <apex:param assignTo="{!AccId}" name="accname" value="{!acc.id}"/>
                        </apex:actionSupport>
                    </apex:column>
                    <apex:column value="{!acc.Name}"/>
                    <apex:column value="{!acc.Phone}"/>
                </apex:pageBlocktable>
            </apex:pageBlockSection>
            
            <apex:outputPanel id="conSection">
                <apex:pageBlockSection title="Related Contact" id="conpgblk" rendered="{!display}" >
                    <apex:outputPanel rendered="{!listWrapper.size != 0}">
                        <div align="center" >
                            <apex:commandButton value="Send Email" action="{!SendEmail}"/>
                            <apex:commandButton value="Print Detail" action="{!PrintDetail}"/>
                        </div>
                        <apex:pageBlockTable value="{!listWrapper}" id="pbt1" var="wrap">
                            <apex:column headerValue="Select">
                            <apex:inputCheckbox value="{!wrap.checked}" id="inputBox"/>
                            </apex:column>
                            <apex:column value="{!wrap.con.Name}"/>
                            <apex:column value="{!wrap.con.Phone}"/>
                            <apex:column value="{!wrap.con.Email}"/>
                            <apex:column value="{!wrap.con.Account.Name}"/>
                            <apex:column value="{!wrap.con.AccountId}"/>
                            <apex:column value="{!wrap.con.Id}"/>
                        </apex:pageBlockTable>
                    <apex:commandButton value="First Page" rerender="conpgblk" action="{!FirstPage}" disabled="{!prev}"/>
                    <apex:commandButton value="Previous" rerender="conpgblk" action="{!previous}" disabled="{!prev}"/>
                    <apex:commandButton value="Next" rerender="conpgblk" action="{!next}" disabled=""/>
                    <apex:commandButton value="Last Page" rerender="conpgblk" action="{!LastPage}" disabled="{!disable}"/> 
                    </apex:outputPanel>
                    <apex:outputPanel rendered="{!listWrapper.size == 0}">
                        <b> NO RELATED CONTACTS FOR THIS ACCOUNT.</b> 
                    </apex:outputPanel>
                </apex:pageBlockSection>
            </apex:outputPanel>
        </apex:pageblock>
    </apex:form>
</apex:page>
 
<apex:page controller="SearchRecords" action="{!showContact1}" showHeader="false" sidebar="false">
    <script>
        function openPopup(){
             window.open('/apex/AttachmentPage','mywindow','width=600,height=400');
        }    
    </script>
    <apex:form >
        <apex:pageBlock title="Send Email To Selected Contacts">
            <div align="Middle">
                <apex:commandButton value="Send" action="{!Send}" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:commandButton value="Add File" onclick="openPopup();return false;"/> &nbsp;&nbsp;&nbsp;&nbsp;
                <apex:commandButton value="Cancel" action="{!Cancel}"/>&nbsp;&nbsp;&nbsp;&nbsp;
            </div>
            <apex:pageBlockSection title="Email" columns="1">
                <apex:repeat value="{!listWrapper1}" var="wrap">
                    To:<apex:outputfield value="{!wrap.con.Name}" />
                </apex:repeat>
                <div class = "requiredInput">
                    Subject<div class = "requiredBlock"></div>
                    <apex:inputText title="Subject" required="true"/>
                </div>
                <apex:inputtextarea label="Body" richtext="true" value="{!Body}" cols="50" rows="15"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 Hope this will help you. Let me know if it helped or you need any more assistance. 

Please mark this is as the solution if it solved your purpose.

Thanks,
Sohan Raj Gupta 

All Answers

Sohan Raj GuptaSohan Raj Gupta
Hi Raghav,

You can use below code:
 
public class SearchRecords {
    public boolean display{get;set;}
    public boolean disable{get;set;}
    public String AccId{get;set;}
    public string getstring{get;set;}
    public string selectedvalie{get;set;}
    public List<Account> accountlist {get;set;}
    public list<Contact> conList{get;set;}
    public list<Attachment> AttachmentList{get;set;}
    private integer totalRecs = 0;
    private integer OffsetSize = 0;
    private integer LimitSize=3;
    public  contact con{get;set;}
    public  Attachment Att{get;set;}
    public  string Body{get;set;}
    public string Subject{get;set;}
    public string selectAttachment{get;set;}
    public boolean Attc{get;set;}
    public boolean Docu{get;set;}
    public boolean SysFil{get;set;}
    public List<WrapperClass> listWrapper {get;set;}
    public List<WrapperClass> listWrapper1 {get;set;}
    public void searchRecord(){
        display=False;
        accountlist= new list<Account>();
        if(getstring!=null){
            accountlist= Database.query('select id,AccountNumber,name,Phone from Account where name like \'%'+getstring+'%\'');
        }
    } 
    public void newClick(){
        disable=false;
        LimitSize=3;
        OffsetSize=0;
        showContact();
    }
    public void showContact(){
        display=true;
        listWrapper = new List<WrapperClass>();
        List<Contact> conlist =[SELECT id,Title,Fax,Birthdate,Name,Account.Name,Phone,Email FROM Contact WHERE AccountId=:AccId LIMIT :LimitSize OFFSET :OffsetSize];
        if(conlist!=NULL){
            totalRecs = conlist.size();
            for(contact con:conlist)
            {
                listWrapper.add(new WrapperClass(con));
            }
        }
    }
    
    public void showContact1(){
        string id = ApexPages.currentPage().getParameters().get('id');
        string[] ids = id.split(',');
        
        display=true;
        listWrapper1 = new List<WrapperClass>();
        List<Contact> conlist =[SELECT id,Title,Fax,Birthdate,Name,Account.Name,Phone,Email FROM Contact WHERE ID IN :ids LIMIT :LimitSize OFFSET :OffsetSize];
        if(conlist!=NULL){
            totalRecs = conlist.size();
            for(contact con:conlist)
            {
                listWrapper1.add(new WrapperClass(con));
            }
        }
        
    }
    
    
    public pageReference PrintDetail(){
        listWrapper1=new list<WrapperClass>();
        for(WrapperClass wr: listWrapper){
            if(wr.checked==true)
                listWrapper1.add(wr);
        }
        pageReference acctPage = new pageReference('/Apex/printContactDetail');
        return acctPage;
    }
 
    public pageReference SendEmail(){
        listWrapper1=new list<WrapperClass>();
          String str='';
        for(WrapperClass wr: listWrapper){
            if(wr.checked==true){
                listWrapper1.add(wr);
            str+=wr.con.id+',';
            }
            system.debug('====>listWrapper1'+listWrapper1);
        }
        str=str.removeEnd(',');
        pageReference EmailPage = new pageReference('/Apex/EmailDetail?id='+str);
        emailPage.setRedirect(true);
            return EmailPage;
    }
    public pageReference AddFile(){
        String str=ApexPages.currentPage().getParameters().get('id');
        PageReference acctPage = new pageReference('/Apex/AttachmentPage?id='+str);
        return acctPage;
    }
    set<id> contactId=new set<Id>();
    
    public void Attachment(){
       String str1=ApexPages.currentPage().getParameters().get('id');
        system.debug('---line81'+str1);
        for(string st:str1.split(',')){
            contactid.add(st);
        }
       AttachmentList=[select Id,Name,Body,BodyLength,ContentType,ParentId from Attachment where ParentId IN:contactId];
        system.debug('AttachmentList'+AttachmentList);
    }
    public void HideShow(){
        system.debug('selectAttachment'+selectAttachment);
        if(selectAttachment=='Attachment'){
            Attc=True;
            Docu=False;
            SysFil=False;
            Attachment();
        }
        else if(selectAttachment=='Document'){
            Attc=False;
            Docu=True;
            SysFil=False;
        }
        else if(selectAttachment=='System File'){
            Attc=False;
            Docu=False;
            SysFil=True;
        }
    }
    public pageReference Send(){
        return null;
    }
    public pageReference Cancel(){
        return null;
    }
    public void FirstPage(){
        disable=false;
        OffsetSize = 0;
        showContact();
    }
    public void previous(){
        disable=false;
        OffsetSize = OffsetSize - LimitSize;
        showContact();
    }
    public void next(){
        OffsetSize = OffsetSize + LimitSize;
        showContact();
    }
    public void LastPage(){
        disable=true;
        OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
        showContact();
        
    }
    public boolean getprev(){
        if(OffsetSize == 0)
            return true;
        else
            return false;
        
    }
    public boolean getnxt(){
        if((OffsetSize + LimitSize) > totalRecs)
            return true;
        else
            return false;
    }

    public pageReference Save(){
            return null;
        }
    public class WrapperClass {
        public Boolean checked {get;set;}
        public contact con {get;set;}
        public WrapperClass(contact con) {
            this.con=con;
            checked=false;
        }
    }
}
 
<apex:page controller="SearchRecords"  showHeader="false" sidebar="false" >
    <apex:form id="frm">
        <apex:pageblock >
            <apex:pageBlockSection title="Search Account Records" columns="1">
                Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
                <apex:commandButton action="{!searchRecord}" value="Search" id="theSearch" reRender="frm"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Account Detail" id="pb">
                <apex:pageBlocktable value="{!accountlist}" var="acc">
                    <apex:column >
                        <input type="radio" name="group1" reRender="{!display}" />
                        <apex:actionSupport event="onclick" action="{!newClick}" reRender="conSection"  >
                            <apex:param assignTo="{!AccId}" name="accname" value="{!acc.id}"/>
                        </apex:actionSupport>
                    </apex:column>
                    <apex:column value="{!acc.Name}"/>
                    <apex:column value="{!acc.Phone}"/>
                </apex:pageBlocktable>
            </apex:pageBlockSection>
            
            <apex:outputPanel id="conSection">
                <apex:pageBlockSection title="Related Contact" id="conpgblk" rendered="{!display}" >
                    <apex:outputPanel rendered="{!listWrapper.size != 0}">
                        <div align="center" >
                            <apex:commandButton value="Send Email" action="{!SendEmail}"/>
                            <apex:commandButton value="Print Detail" action="{!PrintDetail}"/>
                        </div>
                        <apex:pageBlockTable value="{!listWrapper}" id="pbt1" var="wrap">
                            <apex:column headerValue="Select">
                            <apex:inputCheckbox value="{!wrap.checked}" id="inputBox"/>
                            </apex:column>
                            <apex:column value="{!wrap.con.Name}"/>
                            <apex:column value="{!wrap.con.Phone}"/>
                            <apex:column value="{!wrap.con.Email}"/>
                            <apex:column value="{!wrap.con.Account.Name}"/>
                            <apex:column value="{!wrap.con.AccountId}"/>
                            <apex:column value="{!wrap.con.Id}"/>
                        </apex:pageBlockTable>
                    <apex:commandButton value="First Page" rerender="conpgblk" action="{!FirstPage}" disabled="{!prev}"/>
                    <apex:commandButton value="Previous" rerender="conpgblk" action="{!previous}" disabled="{!prev}"/>
                    <apex:commandButton value="Next" rerender="conpgblk" action="{!next}" disabled=""/>
                    <apex:commandButton value="Last Page" rerender="conpgblk" action="{!LastPage}" disabled="{!disable}"/> 
                    </apex:outputPanel>
                    <apex:outputPanel rendered="{!listWrapper.size == 0}">
                        <b> NO RELATED CONTACTS FOR THIS ACCOUNT.</b> 
                    </apex:outputPanel>
                </apex:pageBlockSection>
            </apex:outputPanel>
        </apex:pageblock>
    </apex:form>
</apex:page>
 
<apex:page controller="SearchRecords" action="{!showContact1}" showHeader="false" sidebar="false">
    <script>
        function openPopup(){
             window.open('/apex/AttachmentPage','mywindow','width=600,height=400');
        }    
    </script>
    <apex:form >
        <apex:pageBlock title="Send Email To Selected Contacts">
            <div align="Middle">
                <apex:commandButton value="Send" action="{!Send}" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:commandButton value="Add File" onclick="openPopup();return false;"/> &nbsp;&nbsp;&nbsp;&nbsp;
                <apex:commandButton value="Cancel" action="{!Cancel}"/>&nbsp;&nbsp;&nbsp;&nbsp;
            </div>
            <apex:pageBlockSection title="Email" columns="1">
                <apex:repeat value="{!listWrapper1}" var="wrap">
                    To:<apex:outputfield value="{!wrap.con.Name}" />
                </apex:repeat>
                <div class = "requiredInput">
                    Subject<div class = "requiredBlock"></div>
                    <apex:inputText title="Subject" required="true"/>
                </div>
                <apex:inputtextarea label="Body" richtext="true" value="{!Body}" cols="50" rows="15"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 Hope this will help you. Let me know if it helped or you need any more assistance. 

Please mark this is as the solution if it solved your purpose.

Thanks,
Sohan Raj Gupta 
This was selected as the best answer
Gopal ChatGopal Chat
Thanks its working