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
DocMagicDocMagic 

When sending an email template and using the class 'SingleEmailMessage', can the sent email be attached to the case for reference?

When using auto-responders for email-to-case, the outbound emails are attached to the case. I'd like to perform the same action, when I am sending outbound emails via my own inbound email handler.

In my specific usage case (my custom inbound email handler), I am setting the 'targetObjectId' to a dummy contact (as a contact is required for emailing templates) and the 'WhatId' to the case id. There is no record of my email being sent out (though they are being sent, as can be seen when testing 'live').

I do have experience with creating an EmailMessage object and attaching it to a case (via parentId). I would think that an outbound message would 'magically' attach itself to a given object, but there is no method for specifying it as such.

Any help would be appreciated. Thanks!
Sonam_SFDCSonam_SFDC
Hi,

I understand that you wish to attach the email you are sending using outbound email feature to the Activity related list - I think you will have to create a task out of the email that you are sending for it to show as a completed task under activity history:

read more: 
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_task.htm
https://developer.salesforce.com/forums?id=906F00000008m6LIAQ