Apex code to send Mail
Requirement: Apex code to send mails.
Solution: This can be achieved by writing Apex code.
Apex Code:
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 });
}
}
Go to Developer console ===> Debug ===> Open Execute Anonymous Window:
EmailManagers Email = new EmailManagers();
Email.Sendmail('abc@xyz.com', 'Salesforce Blog!', 'Welcome to my Blog');
Cheers !
Solution: This can be achieved by writing Apex code.
Apex Code:
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 });
}
}
Go to Developer console ===> Debug ===> Open Execute Anonymous Window:
EmailManagers Email = new EmailManagers();
Email.Sendmail('abc@xyz.com', 'Salesforce Blog!', 'Welcome to my Blog');
Cheers !
wonderful post! Thank you for sharing this infowith us.keep updating imwould like to know more
ReplyDeleteupdates on this topic very useful context I would i like to suggest this blog to my friend.
Cloud Computing Classes in Chennai
Cloud Courses in Chennai
Cool and that i have a swell give: Where To Start Renovating House average remodel cost
ReplyDelete