You need to sign in to do that
Don't have an account?
Rahul
Unable to add Multiple Email recipient address in the the To : while sending email
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>
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>
Please make the following change in your controller.
Please make it the best if resolve your issue.
All Answers
You can run it as a anonymous code using developer console for testing :
Please make the following change in your controller.
Please make it the best if resolve your issue.