You need to sign in to do that
Don't have an account?
Rahul Kumar 96
CSV with special character
I am facing some issue reading CSV file from email attachment:
CSV attachments containing any special character gives me invalid BLOB error. ( My attachments contains " é " French character and similar keywords.)
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
if (email.binaryAttachments != null && email.binaryAttachments.size() > 0) {
for (integer i = 0 ; i < email.binaryAttachments.size() ; i++) {
Blob fileContent = email.binaryAttachments[i].body;
String[] elements = fileContent.toString().split(';|\n');
Exception: StringException: BLOB is not a valid UTF-8 string
Thanks,
Rahul
CSV attachments containing any special character gives me invalid BLOB error. ( My attachments contains " é " French character and similar keywords.)
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
if (email.binaryAttachments != null && email.binaryAttachments.size() > 0) {
for (integer i = 0 ; i < email.binaryAttachments.size() ; i++) {
Blob fileContent = email.binaryAttachments[i].body;
String[] elements = fileContent.toString().split(';|\n');
Exception: StringException: BLOB is not a valid UTF-8 string
Thanks,
Rahul
blobString = EncodingUtil.urlEncode(originalString, 'UTF-8');
For more information check out https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_encodingUtil.htm
https://www.codengine.in/2019/06/blob-is-not-a-valid-utf-8-string-salesforce-apex.html