• Kameswari T Padmanaban
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi, 

I have implemented a class which received an email with similar to:

 

Subject: RE:APPL001

Approved

The second Line

 

As you can see the body has two lines: 

1st Line : Approved

2nd Line: The second Line

 

My class is as follows: 

 

 

global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env)
    {
        // Indicates if the message processes successfully, permits an error response to be send back to the user 
        Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
        try
        {

 

global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env)    {        

Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();        
try        {
	System.debug('plainTextBody: ' + email.plainTextBody);
	String[] emailBodyArray = email.plainTextBody.split('\n', 0);
	System.debug('emailBodyArray[0]: ' + emailBodyArray[0]);
	if(emailBodyArray[1]!=null && emailBodyArray[1]!=''){
				comment = emailBodyArray[1];
				System.debug('ApprovalInb comment : ' + comment);
	}
catch (Exception e)
        {
            // Return an email message to the user
            result.success = false;
	}
}

 

 

}

 

When I send the above email, the logs show me: 

15:10:12.670|USER_DEBUG|[20,13]|DEBUG|plainTextBody: ApprovedThe second Line

 

As you can see above, the value of email.plainTextBody hasn't respected the return character between the two lines and has added both lines into one line only, therefore I am not able to process the body into an array with two items. 

Any one know why? 

 

  • June 02, 2010
  • Like
  • 0