I am attempting to identify the format of attachments which come in emails entering my Email Service in order to determine if an attachment is a .csv file.
I was guided to use this as my solution :
email.binaryAttachments[i].mimeTypeSubType.contains('text/csv')
But when I use that the csv file is identified as 'application/vnd.ms-excel'.
What do I use to identify the csv file as 'text/csv' ?
Here is my current code :
global class FunderApprovalEmailServiceCtr implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email,Messaging.InboundEnvelope envelop)
{
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
Integer version = 0;
if (email.binaryAttachments != null && email.binaryAttachments.size() > 0)
{
Map<Id, Program_Contact_Role__c> mapPCRsWithProgram = new Map<Id, Program_Contact_Role__c>();
List<ContentVersion> contentVersions = new List<ContentVersion>();
for(integer i =0, s = email.binaryattachments.size(); i < s; i++) {
if(email.binaryAttachments[i].mimeTypeSubType.equals('application/vnd.ms-excel','text/csv')) {
Somebody originally pointed out ContentType to me which appears to be EmailFileAttachment but I was told that doesn't apply to inbound email. But if that's the proper way to go could you please show me how I would fit that into this code ?
Thank you very much for your help.