You want to retrieve an attached
resume from the job applicant's incoming email and associate the attachment
with the job application.
Verify that the incoming email
message has an attached file. Create an attachment from the file and
associate the attachment with the job application.
looks for a binary file attachment (for example, a PDF) that we can
associate with a Job Application as a resume:
//Searches the email for binary attachments and
// associates them with the job application
if (email.binaryAttachments !=
null && email.binaryAttachments.size() > 0)
for (integer i = 0 ; i < email.binaryAttachments.size() ; i++)
Attachment a = new Attachment(ParentId = newJobApplication.Id,
Name = email.binaryAttachments[i].filename,
Body = email.binaryAttachments[i].body);
- This example searches for binary attachments only. You would also
need to consider other attachment types, such as text file attachments.
You can define different actions depending on the type of attached
- To view incoming email status and debug any processing errors,
view the debug logs created when email services Apex code executes. See “Monitoring Debug Logs” in the Salesforce.com online
- For a complete example containing code from all the email recipes,
see Email Recipes—Complete Code Example.