none
Replying to Postitem created through EWS doesn't chain the conversation RRS feed

  • Question

  • If I create a PostItem using Exchange WebServices and then in Outlook calls Reply() on that PostItem then the Reply MailItem isn't chained off the PostItem. If I create the PostItem in Outlook then calls Reply() everything works correctly.

    I discovered that the PostItem created using EWS had OutlookInternalVersion = 0. When PostItem is created using Outlook then OutlookInternalVersion has been filled with 154615.

    Is this a bug in EWS?

    Best regards Esben Rud Nielsen, Bankdata, DK

    Friday, December 4, 2015 12:55 PM

Answers

  • I would suggest you start by setting the IndexTracking property to true else you will end up with all the conversationId properties being set to the same value for the same subject eg

                ExtendedPropertyDefinition PR_CONVERSATION_INDEX_TRACKING = new ExtendedPropertyDefinition(0x3016, MapiPropertyType.Boolean);
                historyItem.SetExtendedProperty(PR_CONVERSATION_INDEX_TRACKING, true);

    Cheers
    Glen

    Wednesday, December 9, 2015 4:38 AM

All replies

  • If I create a PostItem using Exchange WebServices and then in Outlook calls Reply() on that PostItem then the Reply MailItem isn't chained off the PostItem. If I create the PostItem in Outlook then calls Reply() everything works correctly.

    I discovered that the PostItem created using EWS had OutlookInternalVersion = 0. When PostItem is created using Outlook then OutlookInternalVersion has been filled with 154615.

    To me this seems like a bug in EWS or in Outlook.

    Best regards Esben Rud Nielsen, Bankdata, DK

    Friday, December 4, 2015 7:25 AM
  • Hello Esben,

    I don't see a bug in the OOM - when you create a post item and then call the Reply method all works correctly. So, I'd suggest posting EWS specific questions on the Exchange Server Development  forum.

    Friday, December 4, 2015 9:52 AM
  • I have now asked a question in the EWS forum.
    Friday, December 4, 2015 12:56 PM
  • >>EWS had OutlookInternalVersion = 0. When PostItem is created using Outlook then OutlookInternalVersion has been filled with 154615

    The property just gives you the version of Outlook that created the Item which is only useful for debugging.

    I can't produce your issue what version/service pack/rollup is this occurring on ? What is important for a client to chain a conversion is the Conversation properties https://msdn.microsoft.com/en-us/library/ee158551(v=exchg.80).aspx so I would suggest investigation those properties.

    Cheers
    Glen

    Monday, December 7, 2015 4:09 AM
  • My program references the EWS 2.2 assembly.

    Outlook version is 2013 (15.0.4615.1000) 32 bit

    Exchange version is 15.0.1130.4005

    In Outlook as well with EWS I don't use the Conversation properties, I can post my code if you want it.

    Regards

    Esben

    Monday, December 7, 2015 7:24 AM
  • I would suggest posting your code, the conversation properties is how the Items are threaded so I would also suggest you check with a MAPI editor what these properties are getting set eg compare with an Item that works as expected vs one that doesn't (eg ConversationId,Topic etc). It sounds like one of these isn't being set correctly when using EWS, if that's the case the easy fix is probably just to set the extended property yourself.

    Cheers
    Glen

    Tuesday, December 8, 2015 4:56 AM
  • My code comes here:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Threading.Tasks;
    
    using Microsoft.Exchange.WebServices.Data;
    using Outlook = Microsoft.Office.Interop.Outlook;
    
    namespace ConsoleApplication25
    {
     class Program
     {
      static void Main(string[] args)
      {
       CreateHistoryItemUsingExchange("30130438");
       CreateHistoryReply("30130438");
       return;
      }
      
      static string MESSAGE_HISTORY_FOLDER_NAME = "SMS-historik";
    
      static void CreateHistoryItemUsingExchange(string subject)
      {
       var service = new ExchangeService();
       service.UseDefaultCredentials = true;
       service.AutodiscoverUrl("eru@bankdata.dk");
       var folderView = new FolderView(100);
       var historyFolder = service.FindFolders(WellKnownFolderName.MsgFolderRoot, folderView).Where(f => f.DisplayName == MESSAGE_HISTORY_FOLDER_NAME).First();
       var historyItem = new PostItem(service);
       historyItem.Subject = subject;
       historyItem.IsRead = true;
       historyItem.Save(historyFolder.Id);
      }
    
      static void CreateHistoryReply(string subject)
      {
       var type = Type.GetTypeFromProgID("Outlook.Application");
       var outlook = Activator.CreateInstance(type) as Outlook.Application;
       var mapi = outlook.Session;
       var rootFolder = mapi.DefaultStore.GetRootFolder();
       var historyFolder = rootFolder.Folders.Cast<Outlook.MAPIFolder>().FirstOrDefault(f => f.Name == MESSAGE_HISTORY_FOLDER_NAME);
       var historyItem = historyFolder.Items.Find("[Subject] = '" + subject + "'") as Outlook._PostItem;
       var reply = historyItem.Reply();
       reply.Body = "hello.";
       reply.Save();
      } 
    
    }
    
     

    In order to run the code, you have to create a new folder called "SMS-historik" in your mailbox. The first method creates a PostItem in folder SMS-historik using EWS. The second method locates the PostItem and replies on it. The Reply isn't chained off the PostItem as it would be, if I create the PostItem through Outlook.

    Regards Esben

    Tuesday, December 8, 2015 6:21 AM
  • I would suggest you start by setting the IndexTracking property to true else you will end up with all the conversationId properties being set to the same value for the same subject eg

                ExtendedPropertyDefinition PR_CONVERSATION_INDEX_TRACKING = new ExtendedPropertyDefinition(0x3016, MapiPropertyType.Boolean);
                historyItem.SetExtendedProperty(PR_CONVERSATION_INDEX_TRACKING, true);

    Cheers
    Glen

    Wednesday, December 9, 2015 4:38 AM
  • That solved my problem, thanks a lot for helping me with this matter.
    Wednesday, December 9, 2015 7:01 AM