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

Execute trigger on Email Message and Update Attachment ParentId

Can anybody help me how can i do this

When an email  record is created and linked to a Case, then attachment files linked to the email record moved to be part of the Attachments related list for the Case, not the Email.


My trigger code is



trigger emailAttachment on EmailMessage (after insert) {
 Attachment[] atts = new Attachment[] {};
 for (Attachment a : [Select ID, ParentID From Attachment Where ParentID IN:])
  a.ParentId = trigger.newMap.get(a.ParentID).ParentID;
 if (!atts.isEmpty())
  update atts;



this is giviming me no rows.

how can i do this? can anybody help me plz ?

Thanks in Advance


can anybody guide me how can i do this ?


Thanks in Advance


Please if any response ,it would be helpfull