function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sri549Sri549 

Activities are not Displayed under Case Object

Hi Friends,

I have a req, Whenever the email has been sent, it should attach to activities section related list as an email sub type, earlier it used to attach all the emails which i have sent(I didn't write any code in back end to work). I don't for some reason email stopped attaching to the activities section. Could some one help me What might be the reason behind.

Appreciate, your help!

Thanks!
Srinivas
PriyaPriya (Salesforce Developers) 
Hey Sri,

How do you sending the email ? Is it getting sent by some workflow/Process builder / Flow or due to some code or sending it manually?

Thanks
Sri549Sri549
HI , I am sending email through apex. *Thanks!* *Srinivas Gupta Kotha* Sr.Technical Lead, Innovation - IT. USAA Tel: +1 619 361 0371 9835 Fredericksberg Rd, San Antonio, TX, 78240, USA Linked In URL : https://www.linkedin.com/in/srinivas-gupta-kotha-43123498
PriyaPriya (Salesforce Developers) 
Hi Sri, 

To solve this issue, we will just need to set the flag saveAsActivity = true to the Messaging.SingleEmailMessage object. For example: 
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

mail.setTargetObjectId(userId);
mail.setSubject(subject);
mail.setPlainTextBody(body);
mail.saveAsActivity = true;

If this solve, kindly mark it as best answer.

Thanks!
Sri549Sri549
SaveAsActivity must be false, When sending email to users right. that blocked me to set SaveAsActivity to false *Thanks!* *Srinivas Gupta Kotha* Sr.Technical Lead, Innovation - IT. USAA Tel: +1 619 361 0371 9835 Fredericksberg Rd, San Antonio, TX, 78240, USA Linked In URL : https://www.linkedin.com/in/srinivas-gupta-kotha-43123498