MIME Entry null

Hi:

We have an agent running before new mails arrived, the agent verify if the sender is in the white list and if yes, change the subject based on data getted from a pdf attachment in the same email, after the email reachs the inbox a rule may match the condictions and apply actions on the email.

We have the agent running fine in release 8.0.1 AIX 3 5. Recently the server was upgraded to 8.5.1 FP2 and then the problem started.(our development environment stays in 8.0.1 and we dont have access to the logs of production server)

When an email is coming from internet (MIME) or an internal account (sent as MIME) with a pdf attached and the customer is in white list, the getMIMEEntity is retrieving null, so the agent sends an error :

Started running agent ‘PreProcessor’ on

.

.

.

05/07/2010 10:11:13: INFO: Email is not MIME.

05/07/2010 10:11:13: ERROR: LOG0051There was an error in the PreProcessor, specifically ‘Attachment is unreadable’. The reported message is: not allowed to access or modify file: /tmp/eo806918116tm

If the email has an HTML attachment or no attachment at all , its working fine.

If the sender is not in the white list, the email reachs the inbox and after i checked with a second manual agent if the email is MIME (getMimeEntity), it is.

Only when the sender is in white list and pdf attachment, the email is not recognized as MIME. After the email reachs the inbox the attached file is not showing the acrobat icon but a grey sheet.

Below the code in the agent:

logDebugMessage(“Checking if email is MIME…”); //$NON-NLS-1$

    MIMEEntity theMIMEEntity = null;

    try

    {

        theMIMEEntity = theEmailDocument.getMIMEEntity();

        

        if (theMIMEEntity != null) 

        {

            try

            {

                theSession.setConvertMIME(false);

                

                if("multipart".equals(theMIMEEntity.getContentType())) //$NON-NLS-1$

                {

                    logMessage("Email is multipart MIME."); //$NON-NLS-1$

                    LinkedList<MIMEEntity> theEntitiesList = new LinkedList<MIMEEntity>();

                    

                    try

                    {

                        getAllMIMEEntity(theEmailDocument, theEntitiesList);

                    

                        populateAttachmentListForMIME(...);

                    }

                    finally

                    {

                        if(theEntitiesList != null)

                        {

                            for (int i = 0; i < theEntitiesList.size(); i++)

                            {

                                theEntitiesList.get(i).recycle();

                                

                            }

                        }

                    }

                }

                else 

                {

                    logMessage("Email is MIME but not multipart."); //$NON-NLS-1$

                                    

                                            //MIME extraction

                    LinkedList<MIMEEntity> theEntitiesList = new LinkedList<MIMEEntity>();

                    theEntitiesList.add(theMIMEEntity);                  

                    populateAttachmentListForMIME(...);



                    //Not MIME extraction

                    populateAttachmentListForNotMIME(...);

                }

            }

            finally

            {

                //reset the flag back to the original value

                theSession.setConvertMIME(getOriginalConvertMIME());

            }

        }

        else 

        {

            logMessage("Email is not MIME."); //$NON-NLS-1$

            populateAttachmentListForNotMIME(....);

        }

    }

    finally

    {

        if(theMIMEEntity != null)

        {

            theMIMEEntity.recycle();

        }

    }

protected void populateAttachmentListForMIME(…) throws Exception

{

    if(theEntitiesList != null)

    {

        for (int i = 0; i < theEntitiesList.size(); i++)

        {

            MIMEEntity theEntity = theEntitiesList.get(i);

            

            MIMEHeader theHeader = null;

            Stream theStream = null;

            try

            {

                theHeader = theEntity.getNthHeader("Content-Disposition"); //$NON-NLS-1$

                if(theHeader != null)

                {

                    String theValue = theHeader.getHeaderVal(true);

                

                    if(

                            theValue != null && "attachment".equals(theValue) || //$NON-NLS-1$

                            theValue != null && "inline".equals(theValue) //$NON-NLS-1$

                            )

                    {

                        //Found an attachment, so get the file name

                        String theAttachmentFileName = theHeader.getParamVal("filename"); //$NON-NLS-1$

                        

                        //Remove the double quotes

                        if(theAttachmentFileName.startsWith("\"")) //$NON-NLS-1$

                        {

                            theAttachmentFileName = theAttachmentFileName.substring(1);

                        }

                        if(theAttachmentFileName.endsWith("\"")) //$NON-NLS-1$

                        {

                            theAttachmentFileName = theAttachmentFileName.substring(0, theAttachmentFileName.length() - 1);

                        }

                        

                        logDebugMessage("Validating attachment file: " + theAttachmentFileName); //$NON-NLS-1$

                        

                        if(validateAttachmentName(theAttachmentFileName, theValidFileExtentions))

                        {

                            

                                logDebugMessage("Retrieving attachment contents"); //$NON-NLS-1$

                                

                                //Get the attachment contents

                                ByteArrayOutputStream theByteOutStream = null;

                                try

                                {

                                    theByteOutStream = new ByteArrayOutputStream();

                                    theStream = theSession.createStream();

                                    theEntity.getContentAsBytes(theStream);

                                    theStream.getContents(theByteOutStream);

                                    byte[] theAttachmentContents = theByteOutStream.toByteArray();

                                                                                

                                    logMessage("Added attachment " + theAttachmentFileName + " to algorithm input."); //$NON-NLS-1$ //$NON-NLS-2$                                        

                                }

                                finally

                                {

                                    if(theByteOutStream != null)

                                    {

                                        theByteOutStream.close();

                                        theByteOutStream = null;

                                    }

                                }

                            }

                        

                    }

                }    

            }

            finally

            {

                if(theStream != null)

                {

                    theStream.close();

                    theStream.recycle();

                    theStream = null;

                }

                

                if(theHeader != null)

                {

                    theHeader.recycle();

                }

            }                

        }

    }

}

I hope somebody can give us a hint on what to do. We are thinking it can be a problem with the relase 8.5.1 FP2.

TIA.

Soni