You need to sign in to do that
Don't have an account?
How do I save an outbound email message (via a template) in the case email list?
I have a batch Apex process that sends an email message to the contact for a case when some conditions are met via the Messaging.SingleEmailMessage class using an email template as follows:
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setTemplateId(EMT.Id); mail.setUseSignature(false); mail.setBccAddresses(mailTo); mail.setReplyTo('support@XXXXXXXXX'); mail.setTargetObjectId(myContact.Id); mail.setWhatId(myCase.Id); mail.setSaveAsActivity(false);
The code works exactly as I expect, but I also need the message that was sent out to show up in the Email related list of the case (so that we have a copy of the message that was sent attached to the case).
My initial plan was to also add an EmailMessage object to the case via "EmailMessage myEmailMsg = new EmailMessage();" call, but when it came to the TextBody field, I am not sure what I should use here since the message is created via a template.
Does anybody have any suggestions on how to have the outgoing message attached to the case?
Thanks!
Marc
Hi Marc,
I was having a similar issue with sending a single e-mail, and resolved it by removing the following line:
After that, the outgoing e-mail correctly showed up in the Case detail Email list.
Hope this helps,
Andreas