You need to sign in to do that
Don't have an account?
Harsh vardhana 18
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);
}
what are mail.setToAddresses(toAddresses);
mail.setSubject(subject);
mail.setPlainTextBody(body);
they methord Or what ?
I am studing apex and find a lot of difficulty in codes..
if they are objects then why do we have not declared/initilise them?
HI I want to understand the code could any one help me
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);
}
what are mail.setToAddresses(toAddresses);
mail.setSubject(subject);
mail.setPlainTextBody(body);
they methord Or what ?
I am studing apex and find a lot of difficulty in codes..
if they are objects then why do we have not declared/initilise them?
Hi Harsh,
I will try to explain :
In Summary, 'Messaging.sendEmail' method which needs some parameters of type Messaging.SingleEmailMessage to be able to work.
Now that you understood the above, lets understand these :
mail.setToAddresses(toAddresses);
mail.setSubject(subject);
mail.setPlainTextBody(body);
Once you set the properties, the mail variable is ready to be used by 'Messaging.sendEmail' method which sends the email.
If you are a beginner and have never coded before, don't feel disappointed if you do not understand this. just keep practicing and learn gradually. This is tough even for me to understand when I saw the first time or was learning.
Please mark this as answer if I could help you here. In case you have further doubts you can post here. ALso refer to others answers here who may respond correcting me if I missed something or did not explain correctly.
Good Luck.