Pls let me know where did i make a mistake. its urgent.
when i click on send email button it is showing error at multiselect picklist field
Error: j_id0:j_id1:j_id3:Distribution_List: An error occurred when processing your submitted information.
public class sendingemail { Public String subject{get;set;} Public String body{get;set;} Public List<Contact> contactlist; public sendingemail(ApexPages.StandardController controller) { //contact = [select name, lastName, email,Distribution_List__c, Opt_out_Email__c,recordtype.name from Contact where id = :ApexPages.currentPage().getParameters().get('id')]; } public List<Contact> getContact() { return contactlist; } public PageReference send() { contactlist =[select lastName, email,Distribution_List__c, Opt_out_Email__c,recordtype.name from Contact where Opt_out_Email__c = false and Distribution_List__c='DL1;DL2']; // Define the email Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); // Sets the paramaters of the email String addresses; if (Contactlist[0].Email != null) { addresses = Contactlist[0].Email; // Loop through the whole list of contacts and their emails for (Integer i = 1; i < Contactlist.size(); i++) { if (Contactlist[i].Email != null) { addresses += ':' + Contactlist[i].Email; } } } String[] toAddresses = addresses.split(':', 0); email.setSubject( subject ); email.setToAddresses(toAddresses); email.setPlainTextBody( body ); // Sends the email Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email}); return null; }
Hello,
Multiselect picklist values can't be parse through command button. Use Java script to parse them.
As a wrokaround try to surround the field distribution list under<pageBlockSectionItem>, like:
<apex:pageBlockSection title="Test">
<apex:pageBlockSectionItem>
<apex:outputLabel value="Distribution_Lists" for="Distribution_List"/>:<br />
<apex:inputfield value="{!Contact.Distribution_List__c}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>