function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ramlakhanramlakhan 

Reading an email attachment attached to a custom object in apex trigger

Hello,

I am writing a trigger on attachment  where I need to check whether the value of a   field of the  custom object  is  contained in  the email subject line of the email  added as an attachment to the custom object .

Here I  tried converting the attachment blob to string ,but unfortunately its throwing UTF 8 error.I used other methods of EncodingUtil ,but it couldn't help much .

My intention is to decode the email content as a  string without any alteration,then comparing.

Say, field value='Hello'

and the email subject ='RE:Hello'

I want  attachment email blob to  convert into  'RE:Hello'.


(Inbound email handler is outta  context as here email message is added as an attachment  to custom object).

Thanks to all you wonderful guys here !
 
NagaNaga (Salesforce Developers) 
Hi Ramlakhan,

David81Should certainly be possible.  Have a look at  

http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_classes_email_inbound_using.htm

The docs give a basic example of processing inbound emails. 

Please let me know if this helps

Best Regards
Naga kiran
ramlakhanramlakhan
Hi Kiran,
 
I am   not handling any email using inbound email handler,I am trying to get the email message in the form it was written(in english,not binary or any other encoding tech) in apex .I am just creating a scenario so that it can be more clear: I have an email to case set up created in my org.When  a case is opened  in some xyz ticket management system,an email is sent to my org and corresponding case record is created.Now when this case is closed ,the requestor is notified that the case is closed.If this requestor replies back,his email  message is attached to the case (one which was earlier created) as an email attachment. I  want to compare the case subject with this  email's  subject line,if the case subject is contained in the email subject line or body,case status would be set to 'Re-opened'.

Thanks.