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
Padmanabhan KamuniPadmanabhan Kamuni 

Param tag is not working in my code!! assistance needed.

Here is vf page
<apex:page controller="EmailSending">
    <apex:form id="ww">    	
        <apex:pageBlock >
            <apex:pageBlockSection collapsible="false" columns="3" >
            	<apex:pageBlockTable value="{!cts}" var="c">
                	<apex:column headerValue="Name">
                        <apex:commandLink value="{!c.name}" action="{!gettoActivate}" reRender="ww">
                        <apex:param value="{!c.id}" name="varId"/>
                        </apex:commandLink>
                    </apex:column>
                    <apex:column value="{!c.id}" />
                    <apex:column value="{!c.Email}" />
                </apex:pageBlockTable>
           </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Send E-mail" action="{!sendEmail}" />
                <apex:commandButton value="Send VF Template" action="{!sendVFTemp}"/>
                <apex:commandButton value="Send HTML" action="{!sendHTMLTemp}" /> 
                <apex:commandButton action="{!clearit}" value="Reset" reRender="aa" />
            </apex:pageBlockButtons>            
            <apex:pageBlockSection columns="3" id="aa" >            
                <apex:inputText value="{!emailAddress}" label="Enter E-mail Address * :" required="true" />                   
                <apex:inputText value="{!subject}" label="Subject :"/>                  
                <apex:inputTextarea value="{!body}" label="Body :"/>         
            </apex:pageBlockSection>
        </apex:pageBlock>
           
    </apex:form>
</apex:page>
And controller 
public class EmailSending {
    public string emailAddress {get;set;}
    public string subject {get;set;}
    public string body {get;set;}
    
    public list<string> forConversition {get;set;}
    public list<contact> cts	{get;set;}
    public String rec {get;set;}
    
    public Task35(){
        forConversition = new List<string>();
      //  cts	=	new list<contact>();
        cts	=	[SELECT Name,ID,Email FROM Contact limit 10];
       // gg= new Group__c ();
       
    }
    
    public void sendEmail(){
      // subject	=	'the address is'+a;
       //body		=	'this is a test body that is being sent to '+a;
        //system.debug(a);
         Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();       	
       		forConversition.add(emailAddress);               
        		email.setToAddresses(forConversition);
           // System.debug('email'+emailAddress);
        	email.setSubject(subject);
        	email.setPlainTextBody( body );
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});  
       
    }
    public void gettoActivate(){
        system.debug('how are you guys');
        rec	=	ApexPages.CurrentPage().getParameters().get( 'varId' );
         system.debug('recid is'+rec);
       // return new pagereference(rec);
    }
    public void sendHTMLTemp(){
        //system.debug(varID);
        rec	=	ApexPages.CurrentPage().getParameters().get( 'varId' );
        system.debug(rec);
      //  cts	=	[SELECT ID from Contact where ID=:rec];
        EmailTemplate et = [SELECT Id FROM EmailTemplate where name =:'HTML temp1'];
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();       	
       		forConversition.add(emailAddress);               
        		email.setToAddresses(forConversition);
        		email.setTemplateId(et.Id);
        	email.setTargetObjectId(rec);
           // System.debug('email'+emailAddress);
        	//email.setSubject(subject);
        	//email.setPlainTextBody( body );
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }
    public void sendVFTemp(){
         rec	=	ApexPages.CurrentPage().getParameters().get( 'varId' );
        system.debug(rec);
        EmailTemplate et = [SELECT Id FROM EmailTemplate where name =:'VF page e-mail Template'];
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();       	
       		forConversition.add(emailAddress);               
        		email.setToAddresses(forConversition);
        		email.setTemplateId(et.Id);
        	email.setTargetObjectId(rec);
           // System.debug('email'+emailAddress);
        	//email.setSubject(subject);
        	//email.setPlainTextBody( body );
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }
    
    public void clearit(){
        emailAddress = Null;
        subject= Null;
        body= Null;
    }
}


 
Best Answer chosen by Padmanabhan Kamuni
Aslam ChaudharyAslam Chaudhary
Remove Require attribute in below code. You can check this in controller side. If you click on Link form will be validated for email required. So remove this and check. 

 <apex:inputText value="{!emailAddress}" label="Enter E-mail Address * :"required="true" /> 

Let me know if you need any further help!


 

All Answers

Aslam ChaudharyAslam Chaudhary
Where are you calling Task35 function? I hope you need to call this in constructor. 
Padmanabhan KamuniPadmanabhan Kamuni
Hi Aslam,
Please find the updated code still not working.
public class EmailSending {
    public string emailAddress {get;set;}
    public string subject {get;set;}
    public string body {get;set;}
    
    public list<string> forConversition {get;set;}
    public list<contact> cts	{get;set;}
    public String rec {get;set;}
    
    public EmailSending (){
        forConversition = new List<string>();
      //  cts	=	new list<contact>();
        cts	=	[SELECT Name,ID,Email FROM Contact limit 10];
       // gg= new Group__c ();
       
    }
    
    public void sendEmail(){
      // subject	=	'the address is'+a;
       //body		=	'this is a test body that is being sent to '+a;
        //system.debug(a);
         Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();       	
       		forConversition.add(emailAddress);               
        		email.setToAddresses(forConversition);
           // System.debug('email'+emailAddress);
        	email.setSubject(subject);
        	email.setPlainTextBody( body );
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});  
       
    }
    public void gettoActivate(){
        system.debug('how are you guys');
        rec	=	ApexPages.CurrentPage().getParameters().get( 'varId' );
         system.debug('recid is'+rec);
       // return new pagereference(rec);
    }
    public void sendHTMLTemp(){
        //system.debug(varID);
        rec	=	ApexPages.CurrentPage().getParameters().get( 'varId' );
        system.debug(rec);
      //  cts	=	[SELECT ID from Contact where ID=:rec];
        EmailTemplate et = [SELECT Id FROM EmailTemplate where name =:'HTML temp1'];
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();       	
       		forConversition.add(emailAddress);               
        		email.setToAddresses(forConversition);
        		email.setTemplateId(et.Id);
        	email.setTargetObjectId(rec);
           // System.debug('email'+emailAddress);
        	//email.setSubject(subject);
        	//email.setPlainTextBody( body );
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }
    public void sendVFTemp(){
         rec	=	ApexPages.CurrentPage().getParameters().get( 'varId' );
        system.debug(rec);
        EmailTemplate et = [SELECT Id FROM EmailTemplate where name =:'VF page e-mail Template'];
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();       	
       		forConversition.add(emailAddress);               
        		email.setToAddresses(forConversition);
        		email.setTemplateId(et.Id);
        	email.setTargetObjectId(rec);
           // System.debug('email'+emailAddress);
        	//email.setSubject(subject);
        	//email.setPlainTextBody( body );
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }
    
    public void clearit(){
        emailAddress = Null;
        subject= Null;
        body= Null;
    }
}
 
<apex:page controller="EmailSending">
    <apex:form id="ww">    	
        <apex:pageBlock >
            <apex:pageBlockSection collapsible="false" columns="3" >
            	<apex:pageBlockTable value="{!cts}" var="c">
                	<apex:column headerValue="Name">
                        <apex:commandLink value="{!c.name}" action="{!gettoActivate}" reRender="ww">
                        <apex:param value="{!c.id}" name="varId"/>
                        </apex:commandLink>
                    </apex:column>
                    <apex:column value="{!c.id}" />
                    <apex:column value="{!c.Email}" />
                </apex:pageBlockTable>
           </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Send E-mail" action="{!sendEmail}" />
                <apex:commandButton value="Send VF Template" action="{!sendVFTemp}"/>
                <apex:commandButton value="Send HTML" action="{!sendHTMLTemp}" /> 
                <apex:commandButton action="{!clearit}" value="Reset" reRender="aa" />
            </apex:pageBlockButtons>            
            <apex:pageBlockSection columns="3" id="aa" >            
                <apex:inputText value="{!emailAddress}" label="Enter E-mail Address * :" required="true" />                   
                <apex:inputText value="{!subject}" label="Subject :"/>                  
                <apex:inputTextarea value="{!body}" label="Body :"/>         
            </apex:pageBlockSection>
        </apex:pageBlock>
           
    </apex:form>
</apex:page>

Kindly help any developer's out there.
Aslam ChaudharyAslam Chaudhary
Remove Require attribute in below code. You can check this in controller side. If you click on Link form will be validated for email required. So remove this and check. 

 <apex:inputText value="{!emailAddress}" label="Enter E-mail Address * :"required="true" /> 

Let me know if you need any further help!


 
This was selected as the best answer
Padmanabhan KamuniPadmanabhan Kamuni
Hi Aslam,
The code is working fine now. Thank you!!