You are on page 1of 81

Display Format: OF-{0000}

Use profiles to grant the minimum permissions and settings that all users of a particular type need. Then
use permission sets to grant more permissions as needed. The combination of profiles and permission
sets gives you a great deal of flexibility in specifying object-level access.
public class EmailManager {

// Public method

public void sendMail(String address, String subject, String body) {

// Create an email message object

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

String[] toAddresses = new String[] {address};

mail.setToAddresses(toAddresses);

mail.setSubject(subject);

mail.setPlainTextBody(body);

// Pass this email message to the built-in sendEmail method

// of the Messaging class

Messaging.SendEmailResult[] results = Messaging.sendEmail(

new Messaging.SingleEmailMessage[] { mail });

// Call a helper method to inspect the returned results

inspectResults(results);

}
// Helper method

private static Boolean inspectResults(Messaging.SendEmailResult[] results) {

Boolean sendResult = true;

// sendEmail returns an array of result objects.

// Iterate through the list to inspect results.

// In this class, the methods send only one email,

// so we should have only one result.

for (Messaging.SendEmailResult res : results) {

if (res.isSuccess()) {

System.debug('Email sent successfully');

else {

sendResult = false;

System.debug('The following errors occurred: ' + res.getErrors());

return sendResult;

}
+
Where You Can Use Visualforce

1 Open a Visualforce Page from the App Launcher

2 Add a Visualforce Page to the Navigation Bar

3 Display a Visualforce Page within a Standard Page Layout

4 Add a Visualforce Page as a Component in the Lightning App Builder

5 Launch a Visualforce Page as a Quick Action

6 Display a Visualforce Page by Overriding Standard Buttons or Links

7 Display a Visualforce Page Using Custom Buttons or Links

You might also like