+ Start a Discussion
Apex developer 21Apex developer 21 

Error: Unknown property 'email_class.Attachmentwrapper.name'

<apex:page standardController="Opportunity" extensions="email_class">
    <apex:form >
           
        <apex:pageBlock title="Email Details">
        
            <apex:pageBlock title="Reciepient">
                <b>TO: </b><br/><apex:inputText value="{!emailTo}"/><p/>
                <b>CC: </b><br/><apex:inputText value="{!emailCC}"/><br/>
                <br/>
                <b>Subject: </b><br/><apex:inputText value="{!subject}" maxlength="200"/><br/>
                <br/>
                <b>Body: </b><br/><apex:inputTextArea value="{!email_body}" rows="10" cols="100"/>
            </apex:pageBlock>          
                    
     <apex:pageBlock title="Attachments">
        <apex:pageBlockTable value="{!Attachments}" var="wrap">
            <apex:column headerValue="Select">
                <apex:inputCheckbox value="{!wrap.selected }"/>
            </apex:column>
       
       <apex:column value="{!wrap.name}"/>
      
       </apex:pageBlockTable><p/>
       </apex:pageblock>
                
       <apex:commandButton value="Send Email" action="{!send}"/>
       <apex:commandButton value="Canel" action="{!cancel}"/>
            
       </apex:pageBlock>
                           
    </apex:form>    
</apex:page>
public class email_class
{
    
    Public string ToAddresses {get;set;}
    Public string CCAddresses {get;set;}
    Public string opportunityId {get;set;}
    Public string subject {get;set;}
    public string email_body {get;set;}
    public string emailTo {get;set;}
    public string emailCC {get;set;}
    
    public class Attachmentwrapper
    {
        public Attachment acc{get; set;}
        public Boolean selected {get; set;}
        public Attachmentwrapper(Attachment a)
        {
            acc = new Attachment();
            acc = a;
        }
    }
    
               
    public email_class(ApexPages.StandardController controller) {
        opportunityId = ApexPages.currentPage().getParameters().get('id');
    }
    
     List<Attachmentwrapper> AttachmentList = new List<Attachmentwrapper>();
     List<Attachment> selectedAttachments = new List<Attachment>();
       
        public List<Attachmentwrapper> getAttachments()
        {
            for (Attachment a : [select Name, Body, BodyLength from Attachment where ParentId = :opportunityId])
            {      
                AttachmentList.add(new Attachmentwrapper(a));
            }
            return AttachmentList;
        }
    
    Public PageReference send()
    {
  
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); // set the to address
        mail.setToAddresses(new String[] {emailTo});
        string [] ccaddress;
            if(emailCC != null && emailCC.trim() != ''){
            ccaddress = emailCC.split(',',0);
            mail.setCcAddresses(ccaddress);
            }
        mail.setSubject(subject);
        mail.setBccSender(false);
        mail.setUseSignature(false);
        mail.setPlainTextBody(email_body);
        mail.setWhatId(opportunityId);// Set email file attachments 

        selectedAttachments.clear();
        List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
        for(Attachmentwrapper accwrapper : AttachmentList){
        if(accwrapper.selected == true){
        Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
        efa.setFileName(accwrapper.acc.Name);
        efa.setBody(accwrapper.acc.Body);
        fileAttachments.add(efa);
        }
        
        if(!(fileAttachments.isempty()))
            mail.setFileAttachments(fileAttachments);
       
         selectedAttachments.add(accwrapper.acc);
         Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
       }  
        
        PageReference pageRef = new PageReference('/' + opportunityId);
        pageRef.setRedirect(true);
        return pageRef;
        } 
}


 
Akshit HuriaAkshit Huria
//Replace line 21 with this
 <apex:column value="{!wrap.acc.name}" />