Best practice is to ensure that you're not calling the sendEmail() method inside a for loop
NOTE: The code provided below is an example. You should always test code before pushing to production.
//method to send mail to a list of users
public static void DispatchEmail() {
List lstMails = new List();
lst = 20;
for(Integer i : lst) {
Messaging.SingleEmailMessage message = getEmail();
//Construct the email message here by populating the values such as body, subject
//Adding emails to the list
lstMails.add(message);
}
//Sending the email list in a single call.
Messaging.sendEmail(lstMails);
}
public static Messaging.SingleEmailMessage getEmail() {
Messaging.SingleEmailMessage mailMessage = new Messaging.SingleEmailMessage();
mailMessage.setSaveAsActivity(false);
return mailMessage;
}000385111

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.