You need to sign in to do that
Don't have an account?
Michael Foster 5
Problem, Unexpected token '01' Trailhead, Developer Beginner > Developer Console Basics > Navigate and Edit Source Code
I am unable to save the code in the above trailhead lesson. I get a Problem, Unexpected Token '01'. I am having a tough time finding a solution and surprised given its in a trailhead...
01public class EmailMissionSpecialist {
02
03 // Public method
04 public void sendMail(String address, String subject, String body) {
05 // Create an email message object
06 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
07 String[] toAddresses = new String[] {address};
08 mail.setToAddresses(toAddresses);
09 mail.setSubject(subject);
10 mail.setPlainTextBody(body);
11 // Pass this email message to the built-in sendEmail method
12 // of the Messaging class
13 Messaging.SendEmailResult[] results = Messaging.sendEmail(
14 new Messaging.SingleEmailMessage[] { mail });
15
16 // Call a helper method to inspect the returned results
17 inspectResults(results);
18 }
19
20 // Helper method
21 private static Boolean inspectResults(Messaging.SendEmailResult[] results) {
22 Boolean sendResult = true;
23 // sendEmail returns an array of result objects.
24 // Iterate through the list to inspect results.
25 // In this class, the methods send only one email,
26 // so we should have only one result.
27 for (Messaging.SendEmailResult res : results) {
28 if (res.isSuccess()) {
29 System.debug('Email sent successfully');
30 }
31 else {
32 sendResult = false;
33 System.debug('The following errors occurred: ' + res.getErrors());
34 }
35 }
36 return sendResult;
37 }
38
39}
01public class EmailMissionSpecialist {
02
03 // Public method
04 public void sendMail(String address, String subject, String body) {
05 // Create an email message object
06 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
07 String[] toAddresses = new String[] {address};
08 mail.setToAddresses(toAddresses);
09 mail.setSubject(subject);
10 mail.setPlainTextBody(body);
11 // Pass this email message to the built-in sendEmail method
12 // of the Messaging class
13 Messaging.SendEmailResult[] results = Messaging.sendEmail(
14 new Messaging.SingleEmailMessage[] { mail });
15
16 // Call a helper method to inspect the returned results
17 inspectResults(results);
18 }
19
20 // Helper method
21 private static Boolean inspectResults(Messaging.SendEmailResult[] results) {
22 Boolean sendResult = true;
23 // sendEmail returns an array of result objects.
24 // Iterate through the list to inspect results.
25 // In this class, the methods send only one email,
26 // so we should have only one result.
27 for (Messaging.SendEmailResult res : results) {
28 if (res.isSuccess()) {
29 System.debug('Email sent successfully');
30 }
31 else {
32 sendResult = false;
33 System.debug('The following errors occurred: ' + res.getErrors());
34 }
35 }
36 return sendResult;
37 }
38
39}
Paul S.
It looks like you've pasted the line numbers in with the rest of the code.