outlookvstooffice-jsoffice-addinsoutlook-web-addins

why VSTO Outlook Add-in and Office JS add-in conversationId is not same?


why VSTO Outlook Add-in and Office JS add-in conversationId is not same how can I get same in VSTO like in javascript

but javascript conversationId is different then VSTO

using JavaScript mail conversationId = AQQkADAwATNiZmYAZC01OGM3LTFhN2ItMDACLTAwCgAQAEDQN/vy31NNlzWXFRhAMCo=

using vsto mail conversationId = 0776E8C6D9B30D44A4EA16BE9211AA81

using this I am getting conversationId in Office JS add-in

const conversationId = Office.context.mailbox.item.conversationId;

and using this I am getting conversationId in vsto add-in

  // Method to get the Conversation ID of the selected email
  private string GetSelectedEmailConversationId()
  {
      string conversationId = "";

      try
      {
          Outlook.Application outlookApp = new Outlook.Application();
          Outlook.Explorer explorer = outlookApp.ActiveExplorer();

          // Check if any item is selected
          if (explorer.Selection.Count > 0)
          {
              object selectedItem = explorer.Selection[1];
              if (selectedItem is Outlook.MailItem)
              {
                  Outlook.MailItem mailItem = selectedItem as Outlook.MailItem;
                  // Get the Conversation ID of the selected email
                  conversationId = mailItem.ConversationID;
              }
              else
              {
                  System.Windows.Forms.MessageBox.Show("Please select an email.", "No Email Selected", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
              }
          }
          else
          {
              System.Windows.Forms.MessageBox.Show("Please select an email.", "No Email Selected", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
          }
      }
      catch (Exception ex)
      {
          // Handle any errors
          System.Windows.Forms.MessageBox.Show("An error occurred: " + ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
      }

      return conversationId;
  }

Solution

  • The ConversationId property is a computed value, derived from other conversation-related properties, that identifies a message as belonging to a specific conversation. This property is computed by the application, server or client. It seems OfficeJS uses an Exchange computed property value while in Outlook (VSTO) you got a local value computed in Outlook (Extended MAPI).