You need to sign in to do that
Don't have an account?
bhanu reddy 24
i am unable to send a mail to multiple recipients from 'To' field
// sending email to only one person
public class SendMailController {
public String z { get; set; }
public String y { get; set; }
public String x { get; set; }
public void saveMethod() {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
string[] xyz =new string[] {x};
mail.setToAddresses(xyz);
mail.setSubject(y);
mail.setHtmlBody(z);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
// visual force page
<apex:page controller="SendMailController" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:outputLabel value="To"/>
<apex:inputText value="{!x}" />
<apex:outputLabel value="Subject"/>
<apex:inputText value="{!y}"/>
<apex:outputLabel value="Body"/>
<apex:inputTextarea value="{!z}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Send" action="{!saveMethod}" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
public class SendMailController {
public String z { get; set; }
public String y { get; set; }
public String x { get; set; }
public void saveMethod() {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
string[] xyz =new string[] {x};
mail.setToAddresses(xyz);
mail.setSubject(y);
mail.setHtmlBody(z);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
// visual force page
<apex:page controller="SendMailController" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:outputLabel value="To"/>
<apex:inputText value="{!x}" />
<apex:outputLabel value="Subject"/>
<apex:inputText value="{!y}"/>
<apex:outputLabel value="Body"/>
<apex:inputTextarea value="{!z}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Send" action="{!saveMethod}" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
See updated code
All Answers
See
// visual force page
iam asking one (To named field )i will write multiple email address how to send at a time
can you plzz write a program
See updated code