Salesforce | Show Email sent from Salesforce in activity history

Author - Webner
21.07.2016
|
0 Comments
||

Problem : How to show Email sent from Salesforce in activity history of an object

Solution : Here are the steps :

1. Set WhatId

2. Make SaveAsActivity true

Code Sample:

Messaging.SingleEmailMessage emailTobeSent = new   Messaging.SingleEmailMessage(); 
List ToAddress = new List();      
ToAddress.add(‘Example@gmail.com’);
emailTobeSent.setToAddresses(ToAddress);
emailTobeSent.setSubject('Subject);
emailTobeSent.setHtmlBody('Please see the attachments');
emailTobeSent.setWhatid(RecordId);//Put the record id of record for which you want make activity history in place of RecordId.
emailTobeSent.setSaveAsActivity(true); //
Messaging.SendEmailResult [] r1 = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {emailTobeSent});

Webner Solutions is a Software Development company focused on developing CRM apps (Salesforce, Zoho), LMS Apps (Moodle/Totara), Websites and Mobile apps. If you need Salesforce customization, App development or any other software development assistance please contact us at salesforce@webners.com

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published. Required fields are marked *