为什么 VSTO Outlook 加载项和 Office JS 加载项对话 ID 不同?

问题描述 投票:0回答:1

为什么 VSTO Outlook 插件和 Office JS 插件

conversationId
不一样,我怎样才能在 VSTO 中像在 javascript 中一样获得相同的结果

但是 javascript

conversationId
与 VSTO 不同

使用 JavaScript 邮件

conversationId = AQQkADAwATNiZmYAZC01OGM3LTFhN2ItMDACLTAwCgAQAEDQN/vy31NNlzWXFRhAMCo=

使用 vsto 邮件

conversationId = 0776E8C6D9B30D44A4EA16BE9211AA81

使用此我在 Office JS 加载项中获取对话 ID

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

并使用这个我在 vsto 插件中获取对话 ID

  // 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;
  }
outlook vsto office-js office-addins outlook-web-addins
1个回答
0
投票

ConversationId
属性是一个计算值,派生自其他与会话相关的属性,用于将消息标识为属于特定会话。该属性由应用程序、服务器或客户端计算。看起来
OfficeJS
使用 Exchange 计算的属性值,而在 Outlook (VSTO) 中,您获得了在 Outlook(扩展 MAPI)中计算的本地值。

© www.soinside.com 2019 - 2024. All rights reserved.