<apex:page standardController="contact" extensions="testemail">
<apex:form>
<apex:commandButton value="SendEmail" accesskey="{!sendemail}"/>
</apex:form>
</apex:page>
class
public class testemail{
private final list<id> contactids;
public list<contact>con;
public testemail(Apexpages.StandardController Controller)
{
con = [select id from contact limit 250];
for (integer i=0;i<250;i++)
{
contactids.add(con[i].id);
}
}
public void sendemail()
{
Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
mail.setTargetObjectIds(contactids);
Messaging.SendEmail(new Messaging.MassEmailMessage[]{mail});
}
}
Attribution to: user8126
Possible Suggestion/Solution #1
Your apex:commandButton
should probably be:
<apex:commandButton value="SendEmail" action="{!sendemail}"/>
Attribution to: Keith C
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/34072