You need to sign in to do that
Don't have an account?

Messaging.SingleEmailMessage and Messaging.MassEmailMessage
Can some one elaborately describe the : Messaging.SingleEmailMessage and Messaging.MassEmailMessage???? Where we use MassEmailMessage?
-Kaity
EmailTemplate emailTemplateInstance = [select Id from EmailTemplate where Name = 'RFI Notification: Search Criteria'];
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setTemplateId(emailTemplateInstance.Id);
email.setTargetObjectId(c.Owner.ContactId);
email.setWhatId(c.Id);
email.setSaveAsActivity(false);
Messaging.SendEmailResult [] r = Messaging.sendEmail(email);
Please see setWhatId and setTargetObjectId parmaeters.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_email_outbound_mass.htm
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_email_outbound_single.htm
Both are the usefull to send mail , Messaging.SingleEmailMessage for send single mail and Messaging.MassEmailMessage for mass(more then one) mailss ,
This is example for Messaging.SingleEmailMessage
List<Contact> conObj = [SELECT id, name FROM Contact LIMIT 100];
EmailTemplate e = [select id,name from EmailTemplate limit 1];
for(Integer i=0; i < conObj.size(); i++){
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
email.setTargetObjectId(conObj[i].Id);
email.setTemplateId(e.id);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
}
Both are good. You can find the details and the difference in my below post.
http://mindfiresfdcprofessionals.wordpress.com/2013/06/22/sending-mass-email-with-attachment/
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks