Last active
April 1, 2016 03:16
-
-
Save maybe-joe/354331de677e50ebf39e037096049d3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger EmailMessageTrigger on EmailMessage(after insert, after update) { | |
Set<Id> emailsWithAttachments = new Set<Id>(); | |
for(EmailMessage email : Trigger.New){ | |
if (email.Incoming) { | |
emailsWithAttachments.add(email.Id); | |
} | |
} | |
List<Attachment> attachments = [ | |
select Id | |
from Attachment | |
where ParentId in :emailsWithAttachments | |
]; | |
delete attachments; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment