1 Reply Latest reply on Jun 29, 2010 12:18 PM by Reed Powell

    CFEXCHANGEMAIL not finding attachments for a UID

    Reed Powell Level 3

      I run into this same error a while back, and never found a solution for it, and now it is back and becoming more serious so I've got to figure out what is happening.  In a nutshell, I have a CF8 scheduled task that runs once an hour,and looks in various Exchange 2003 inboxes for new unread messages with attachments that need to be detached and passed on via a queue to various SSIS tasks.  For each of the mailboxes it does the following:


      Thiscode is inside of a CFTRY and followed by a CFCATCH to be sure that the login is successful.

      <cfexchangeconnection action = "open" connection = "exchangeConnection"
        protocol = "http" server = "#msxserver#"
        username = "#thisusername#" password = "#sources.Loginpassword#" />



      This should get me a list of the unread emails from the last 10 days

      <cfexchangemail action = "get" name = "inboxtemp" connection = "exchangeConnection">
         <cfexchangefilter name="TimeSent" from="#DateAdd("d","#(-1 * url.TimePeriodToCheck)#", Now())#" to="#Now()#">
         <cfexchangefilter name = "maxRows" value = "9999">
         <cfexchangefilter name="isRead" value="false"> 


      That is just to get a sorted list that I can display

      <cfquery name="inboxTot" dbtype="query">
        SELECT * FROM inboxtemp ORDER BY timereceived DESC


      This is to find only those messages that have attachments

      <cfquery name="inbox" dbtype="query">
        SELECT * FROM inboxTot
        WHERE HasAttachment=1
        ORDER BY timereceived DESC


      Now I try to process each of those messages that has any type of attachment.  The CFEXCHANGEMAIL call is wrapped in a try/catch

      <cfloop query="inbox">

           <cfexchangemail action="getAttachments"

      *** rest of code goes here ***




      This process works 99.9% of the time.  Recently it started failing on the CFEXCHANGMAIL call inside of the CFLOOP, whose purpose is to get the list of attachments for the specific email (since embedded logos, etc., count as an attachment, and I only want to find the messages that have an actual data file attached to them).  The error that comes back from the CFCATCH is:

      Failed to detach attachment:
          Requested Exchange resource was not found on the server.

      Which is confusing since the UID that I passed to it is the same UID that Exchange returned in the earlier call to get the inbox contents. 


      There is one clue:  This started happening at the same time about a week or two ago, for two different mailboxes, and the UIDs for the failing messages look very similar, and different from most of the others for messages that have no problems.  The incoming messages are coming from the same vendor, and other messages from that vendor work fine, but have very different looking UIDs.  Here is the UID of one of the failing messages (partially sanitized since it contains the vendor's email server name and email address):




      here is a sample from a message that is typical of those that work fine:



      Has anyone had any experience with tracking down this sort of problem?  I can log into Outlook Web Access for each of these account, and view all of the messages, including their attachments, with no problems at all.  I don't see any visible differences between the messages that work in CF and those that don't.


      Are there any tools that can be used with Exchange 2003 that would allow me to send it the UID that CF is having problems with, to see if maybe there is more diagnostic data available?  Is there some way to get CF to give me more diagnostic info about the failure?


      Thanks people!