none
EWS Undelivered Mails RRS feed

  • Question

  • While sending mails some mails goes undelivered and bounces back to our Mailbox.

    Is there any way where we can identify the original mail from the undelivered mail? 

    Does exchange saves any relation between them?

    I want to identify the original mail and resend it by doing some correction.

    (EWS Exchange 2007).

     

     

    Friday, October 7, 2011 6:11 AM

All replies

  • Hi,

    see http://www.infinitec.de/post/2011/06/27/Correlating-a-Non-Delivery-Notification-to-its-original-message-with-the-Exchange-Managed-API.aspx.

    When you have identified the message, I suggest you create a copy of it in the drafts folder and send it again using EWS.

    Kind regards,
    Henning

    Friday, October 7, 2011 7:04 AM
  • Hi Henning,

    The above code would run fine with the earlier versions of Exchange which i never worked on i am using Exchange 2007.

    Can you please help me in converting above code for finding correlation into 2007?

    example code goes like this for searching Undelivered mail in Sent items

    "FindItemType findRequest = new FindItemType();

                findRequest.ItemShape = new ItemResponseShapeType();

                findRequest.ItemShape.BaseShape = DefaultShapeNamesType.AllProperties;

                //Paging

                IndexedPageViewType indexedView = new IndexedPageViewType();

                indexedView.BasePoint = IndexBasePointType.Beginning;

                indexedView.MaxEntriesReturned = 10;

                indexedView.MaxEntriesReturnedSpecified = true;

                indexedView.Offset = 0;

                findRequest.Item = indexedView;

                //Specifying the Folder to get Items

                DistinguishedFolderIdType sent = new DistinguishedFolderIdType();

                sent.Id = DistinguishedFolderIdNameType.inbox;

                findRequest.ParentFolderIds = new BaseFolderIdType[] { sent };

                findRequest.Traversal = ItemQueryTraversalType.Shallow;

                //Restriction

                findRequest.Restriction = new RestrictionType();

     

                ContainsExpressionType cet = new ContainsExpressionType();

                // Specify how the search expressoin is compared

                cet.ContainmentComparison = ContainmentComparisonType.IgnoreCase;

                cet.ContainmentComparisonSpecified = true;

                cet.ContainmentMode = ContainmentModeType.FullString;

                cet.ContainmentModeSpecified = true;

     

                // Identify the field to identify the item field to examine

                PathToUnindexedFieldType ptuft = new PathToUnindexedFieldType();

                ptuft.FieldURI = UnindexedFieldURIType.itemItemClass;

                cet.Item = ptuft;

     

                ConstantValueType cvt = new ConstantValueType();

                cvt.Value = "REPORT.IPM.Note.NDR";

     

                // Add the value to the search expression

                cet.Constant = cvt;

     

                findRequest.Restriction.Item = cet;

     

                FindItemResponseType response = binding.FindItem(findRequest);"

     

    Friday, October 7, 2011 9:11 AM
  • Are these internal or external emails?


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Friday, October 7, 2011 10:32 AM
  • These are external emails..
    Friday, October 7, 2011 10:55 AM
  • This is not relevant. As long as Exchange is able to correlate the NDR to it's original message, the property mentioned in my article is set.

    Problems arise when the NDR is a simple text message and not an NDR according to RFC 3461 (http://tools.ietf.org/html/rfc3461). In this case, the NDR does not contain a computer readable reference to the original message.

    Kind regards,
    Henning Krause

    Friday, October 7, 2011 1:18 PM
  • If they were all internal, it wouldn't be an issue, but if they're external a recipient domain that's implementing a "bounce after accept" anti-spam solution could introduce NDR's that aren't in the expected format.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Friday, October 7, 2011 1:29 PM
  • Yes, that's what I have written in that article.

    Kind regards,
    Henning

    Friday, October 7, 2011 1:55 PM
  • I thought it was a relevant question because it would determine whether you could assume that all the DNRs would be issued by the Exchange server, and therefore all be consistent, or if you would have to make allowances for non-standard NDRs.
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Friday, October 7, 2011 2:09 PM
  • Can you guys explain me how to find the Parent Key property in NDR's?

    From the article http://www.infinitec.de/post/2011/06/27/Correlating-a-Non-Delivery-Notification-to-its-original-message-with-the-Exchange-Managed-API.aspx i am not able to figure out how we are getting this property plus i am using Exchange 2007 Proxy where i am not able to find classes like "ExtendedPropertyDefinition" and function "BindToItems". I am very new to Exchange server programming.

    Monday, October 10, 2011 4:54 AM
  • Hi,

    you'll need to execute a GetItem request. Here is the relevant XML:
          <m:GetItem>
           <m:ItemShape>
             <t:BaseShape>IdOnly</t:BaseShape>
             <t:AdditionalProperties>
               <t:ExtendedFieldURI PropertyTag="37" PropertyType="Binary" />
             </t:AdditionalProperties>
           </m:ItemShape>
           <m:ItemIds>
             <t:ItemId Id="AAMkAGY3" />
           </m:ItemIds>
         </m:GetItem>
     After you got your parent Key from the NDR, issue a FindItems request:
          <m:FindItem Traversal="Shallow">
           <m:ItemShape>
             <t:BaseShape>AllProperties</t:BaseShape>
           </m:ItemShape>
           <m:IndexedPageItemView MaxEntriesReturned="1" Offset="0" BasePoint="Beginning" />
           <m:Restriction>
             <t:IsEqualTo>
               <t:ExtendedFieldURI PropertyTag="12299" PropertyType="Binary" />
               <t:FieldURIOrConstant>
                 <t:Constant Value="btdwD+b4/EOX/rpzHMFUow==" />
               </t:FieldURIOrConstant>
             </t:IsEqualTo>
           </m:Restriction>
           <m:ParentFolderIds>
             <t:DistinguishedFolderId Id="sentitems" />
           </m:ParentFolderIds>
         </m:FindItem>

    The class names of the EWS proxy are the same as the XML tag names, so you should be able to work with this.

    Kind regards,
    Henning

    Can you guys explain me how to find the Parent Key property in NDR's?

    From the article http://www.infinitec.de/post/2011/06/27/Correlating-a-Non-Delivery-Notification-to-its-original-message-with-the-Exchange-Managed-API.aspx i am not able to figure out how we are getting this property plus i am using Exchange 2007 Proxy where i am not able to find classes like "ExtendedPropertyDefinition" and function "BindToItems". I am very new to Exchange server programming.

    Monday, October 10, 2011 7:18 AM