I have seen similar answers to what I'm trying to do, but I'm new to Apex so apologies.

I want to create an inbound email address in SFDC to send a pdf invoice to. The custom object is ia_crm__Sales_Invoice__c the field ia_crm__Document_Number__c will be the same as the email subject. (Example INV-000023) (Sent from accounting system so it will always be coming from the same address and subject will be consistent, the document number will be unique and it will exist as a record in SFDC).

I would like to lookup the Sales Invoice custom object record that corresponds to the invoice no. in the subject, delete any existing files on that record and add the pdf email attachment to the files section of the custom object record.

  • 1
    I'm afraid this likely goes against the site's guidelines in that it's asking for quite a lot. But I will throw out some links for you to look into. You will need an Apex Email Service to handle the email, you will need to work with ContentDocuments to attach the PDF to a record. I will recommend that you don't flat out delete all associated files and instead define a way to identify your automated PDF.
    – nbrown
    Jan 12 at 21:30