You need to sign in to do that
Don't have an account?
Shruti Nigam
Hello I want to know to how to send and email notification in the particular scenario where I have create one object in which there are two fields previous owner and new Owner
Hello I want to know to how to send and email notification in the particular scenario where I have create one object in which there are two fields previous owner and new Owner and the situation is that when inm updating account billing postal code Im getting previous owner the one before updating and in new owner im getting value after updating
and now I want to send email notification to both new Owner and Previous Owner telling them there respective place
Previous and new Owner are having static value stored in Users in salesforce
Can anyone help me in this scenario??
and now I want to send email notification to both new Owner and Previous Owner telling them there respective place
Previous and new Owner are having static value stored in Users in salesforce
Can anyone help me in this scenario??
Below class is to send email by using the apex. Pass the EmailAddress, Subject and Body to the below class, then it will send the email.
As Previous and new owner as storing in seperate fields, with that field query the User Object and get the EmailAddress and pass that emailAddress to below class.
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;
}
}
Thanks,
Narendar
You can also do it through the Process Builder. Refer the below links
https://success.salesforce.com/answers?id=90630000000DIzKAAW
https://success.salesforce.com/answers?id=90630000000dqhn
Thanks,
Naren