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
Kalle KalifKalle Kalif 

Recieving information from plain text E-mail and creating a new record

Hi,

 

I am recieving a email with data values for each field in my custom object on seperate lines. Some data are just numbers, others are text (up to 100 characters). The problem is that only the first 60 characters are captured from the text data.

 

Extract of code i am using in apex:

 

//Retrieve data
string r1 = emailBody[2];
string r2 = emailBody[3];
string r3 = emailBody[4];
string r4 = emailBody[5];
string r5 = emailBody[6];
string r6 = emailBody[7];

//input into object
Daily__c r = new Daily__c(Name = RptName, Name__c = Ship[0].ID, Email_from__c = email.fromAddress,
Field1__c = integer.valueof(r1),
Field2__c = integer.valueof(r2),
Field3__c = r3,
Field4__c = decimal.valueof(r4),
Report_date__c = date.valueof(r5),
Comments__c = r6

 

 

 

 

I.E. if there is 100 characters on line 7 in the email, only 60 are captured into Comments__c. How can I fix this?

 



Best Answer chosen by Admin (Salesforce Developers) 
Kalle KalifKalle Kalif

Okay it seems like its caused by outlook auto-wrapping the text, there is a upper limit of 132 characters on each line before the text is wrapped. so unless there is some clever thing i can do with my code (it wont be very easy to change the mail format to html), i have to figure out a way of disabling word wrapping.

 

 

edit: using outlook, i deselect "auto select encoding for outgoing messages" under "international options" under "mail format" in options. Then now newline characters are added by outlook and everything works fine!