• Saransh B
  • NEWBIE
  • 0 Points
  • Member since 2017
  • MUFG

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
Can you please help me to provide a trigger to Create Contact from Leads. Thanks 
Hello friends, I want to add Multiple email address for sending the email in To: input box, but it doesnot accept more than one. Do anyone know how to solve this.
Please find the code below

public class sendemailtestcontroller {

    public sendemailtestcontroller() {

    }





    public String toEmail {get;set;}
    public String subject {get;set;}
    public String body {get;set;}
    
    
    private final Lead MyLead;
    public sendemailtestcontroller(ApexPages.StandardController controller)
    
   
    {
        this.MyLead=(Lead)controller.getRecord();
    } 
   
             
    public void sendEmail() {
        
        //create a mail object to send email 
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        
        String[] toaddress = (new String[]{toEmail});
        
        //email properties
        mail.setToAddresses(toaddress);
        mail.setSubject(subject);
        mail.setUseSignature(true);
        mail.setPlainTextBody(body); 
               
        // send the email
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
     }   
   

}

Vf :
<apex:page standardcontroller="Lead" extensions="sendemailtestcontroller">
  <apex:pageBlock title="EMAIL TEST">
        <apex:form >
        <br />
            <apex:outputLabel value="To" for="To"/>:<br/>
            <apex:inputText value="{!toEmail}" id="email"/><br/><br/>
                        
            <apex:outputLabel value="Subject" for="Subject"/>:<br />     
            <apex:inputTextarea value="{!subject}" id="Subject" cols="80" /><br/><br/>
                        
            <apex:outputLabel value="Body" for="Body"/>:<br />     
            <apex:inputTextarea value="{!body}" id="Body" rows="10" cols="80"/><br/><br/>      
            <br /><br />
                        
            <apex:commandButton value="Send Email" action="{!sendEmail}"  />
            <apex:commandButton value="Cancel" action="{!cancel}"/> 
        
        </apex:form>
    </apex:pageBlock>
</apex:page>

User-added image
  • January 05, 2019
  • Like
  • 0