You need to sign in to do that
Don't have an account?
Bob James 8
Apex Trigger, Inbound Email, File Type
Wondering if anyone has tackled this.
An Apex Trigger that looks at an inbound email (before insert, before update), and if there is an Attachment, and the Attachment is of certain File Types (.zip, .mp4, etc.) it does not create/update the case AND an email is sent to the sender notifying them that File Type is not accepted and to plesse resend their email with accepted File Type (.jpg, .png, .pdf).
An Apex Trigger that looks at an inbound email (before insert, before update), and if there is an Attachment, and the Attachment is of certain File Types (.zip, .mp4, etc.) it does not create/update the case AND an email is sent to the sender notifying them that File Type is not accepted and to plesse resend their email with accepted File Type (.jpg, .png, .pdf).
Yes you can use Messaging.InboundEmailHandler https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_inbound_using.htm to track incoming email to Salesforce and do whatever you want to do there.
Do you have anything already build that you can share and can be helped or do you need from scratch?
I will look at the InboundEmailHandler to see if I can figuer it out from there.
Thank you Abdul.
I'll let you know how it goes.
I hope this code will help you move forward.
Couple of things due you have the format of the Email you are expecting specially when you want to update the case. The email you receive must have some form of Case Id for update.
I have left couple of things blank that you can fill based how you create or update them.
Thank you for your help on this.
In most instances the customer should be responding to us, and in the Subject of their email there should be the Case reference, which looks like this:
ref:_00D3ipdYT._5003iHa68M:ref
ref:_xxxxxxxxx._xxxxxxxxxx:ref
(It should not be the only thing in the Subject, but it should be there.)
The case reference should also appear in the Body.
(We do know that some customers, either on purpose or otherwise, remove these Case references.)
If the Case reference is not there, there is no format, it simply an email from a customer, which would create a new case.
Thanks for the clarity, so where (which field) that ref:_00D3ipdYT._5003iHa68M:ref exists on the Case Level to match.
Regards,
My Question was as you mentioned that
"in the Subject of their email there should be the Case reference, which looks like this:
ref:_00D3ipdYT._5003iHa68M:ref
ref:_xxxxxxxxx._xxxxxxxxxx:ref"
How this is referencing the Case?
How would I going to pull the Case based on this reference?
The actual Case Number is not in the email, this "ref:........:ref" must be there, or a new case will be created.
Salesforce does not care if the actual case number is anywhere in the email, only that this reference is in either the Subject or the Body.
If the "ref:........:ref" is in the Subject or Body, an existing case is updated.
If the "ref:........:ref" is not in the Subject or Body, a new case is created - even if the customer already has a case, if they remove the "ref:........:ref" in their return email, a new case is created.
Sorry for lots of question as I am trying to get my base to update my code accordingly.
If the "ref:...:ref" string is in the inbound email from the customer, the correct case will be updated.
If the "ref:....:ref" is missing, then it will create a new case, and this is OK.
My objective is to not allow certain file types.
Here is the code, atleast this code will as per you objective, allow only types you looking for. Let me know
Did you give a try?