
public class CustomerImpl {
public void sendEmailToCustomer(list<Customer__C>listcust)
{
for (Customer__C cust : listcust){
Messaging.SingleEmailMessage msg= new Messaging.SingleEmailMessage();
msg.setToAddresses(new String[]{Cust.Email_Address__c});
msg.setBccAddresses(new String[] {Cust.Bcc_Address__c});
msg.setSubject('info about session');
msg.setPlainTextBody(cust.comment__c);
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{msg});
}
}
}
Please use below code and let me know if it hepls you. public class CustomerImpl {
public void sendEmailToCustomer(list < Customer__C > listcust) {
List < Messaging.SingleEmailMessage > listOfEmails = new List < Messaging.SingleEmailMessage > (); //Used to store list of emails
for (Customer__C cust: listcust) {
Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage();
msg.setToAddresses(new String[] {
Cust.Email_Address__c
});
msg.setBccAddresses(new String[] {
Cust.Bcc_Address__c
});
msg.setSubject('info about session');
msg.setPlainTextBody(cust.comment__c);
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
attach.setBody(Blob.valueOf('Some Text'));
attach.setFileName('TesAttachmentName.pdf');
attach.setContentType('application/pdf');
attach.setInline(false);
Messaging.EmailFileAttachment[] attachment = new Messaging.EmailFileAttachment[] {
attach
};
msg.setFileAttachments(attachment);
listOfEmails.add(msg);
}
Messaging.sendEmail(listOfEmails, FALSE);
}
}
Thanks & Regards
David Hales(1053)
Kloudrac Software Pvt. Ltd.