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
Susana NTSSusana NTS 

Undeliverable Email to InboundEmailService Class 554 System.TypeException

Hi,

 

I've developed an InboundEmailService Class which receives an email with an XML in its body.

This class gets the plainTextBody out of the email and then parses its content.

 

One of the tag of the XML is this:

 

<OpenDate>2008-02-25 00:00:00</OpenDate> 

 

When sending an email to the salesforce email address, I receive this email with an Exception right in the line where the parser processes that date:

 

>>> hojasdeproyecto@4b9l8nski5qzkyszl2ghlui4j.in.sandbox.salesforce.com (Undelivered): 554 System.TypeException: Invalid date:                            

Class.ParserHojaProyecto.parsearDetalle: line 171, column 24

Class.ParserHojaProyecto.parsearDatos: line 131, column 7

Class.ParserHojaProyecto.parsearEmail: line 43, column 3

Class.RecepcionEmailHojaProyecto.handleInboundEmail: line 28, column 13 External entry point

 

The line where the code throws the exception is:

p.Open_Date__c = Date.valueOf(datos.get(0)); 

 

It seems to me that the parser is taking a blank space as the date value (maybe the one between the date and the time).

 

The weird thing is all my test methods do execute perfectly and the parser extracts every single value as it has to do. Also, the XML I'm using in the email is exactly the same I'm using in the test methods.

 

Any Idea why the development works fine in test methods and does not when sending the physical email?

 

Thanks in advance,

 

Susana

Best Answer chosen by Admin (Salesforce Developers) 
Susana NTSSusana NTS

Solved!

 

Outlook interface inserts a break when the max. characters per line is reached while my code in the test generates a full string as the body of the mail without any break.

 

Put a replace or trim and problem solved :)