Thursday, January 22, 2015

Emails From Salesforce

Sending Emails form salesforce-

There are different ways we can send Emails from salesforce-
Apex code-
You can use Apex to send individual and mass email. The email can include all standard email attributes (such as subject line and blind carbon copy address), use Salesforce email templates, and be in plain text or HTML format, or those generated by Visualforce.


Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'TestUser@test.com'};
String[] ccAddresses = new String[] {'TestUser@test.com'};

// Assign the addresses for the To and CC lists to the mail object.
mail.setToAddresses(toAddresses);
mail.setCcAddresses(ccAddresses);
// Specify the subject line for your email address.
mail.setSubject('Test Email');
// Specify the text content of the email.
mail.setPlainTextBody('This is Just a test Email');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });



Workflow Rule- In this way you need to create an Email template and the email can be sent to specified users based on some conditions specified on worflow rule.




Email Alert

From Records level- Clicking on an Email field on Records opens the outlook mails associated with salesforce and email can be sent to particular user.

No comments:

Post a Comment