【问题标题】:How do I retrieve a UID from a ICS file being accepted in an Outlook add in?如何从 Outlook 加载项中接受的 ICS 文件中检索 UID?
【发布时间】:2017-07-04 16:32:10
【问题描述】:

感谢收看。

我正在开发一个 Outlook 插件,并且需要在用户接受时访问嵌入在 .ics 文件中的 UID 值:

如果我查看 .ICS 文件中的原始数据,我可以看到 UID 在那里:

我想知道当用户接受会议时会触发什么事件(我可以附加到该事件),一旦我获得了被接受的 Outlook 对象,我如何从中检索 UID?

更新:

感谢 Dmitry Streblechenko 的帮助,我现在了解到全局约会 ID 只是 UID 的编码版本。他的工具OutlookSpy在看到这一点时非常有用。也就是说,我仍然停留在最后一部分,即将全局约会 ID 转换为 C# 中的 UID。 Google 将我带到此示例以转换 EntryId 属性,但我找不到正确的架构或十六进制代码来获取全局约会 ID 属性和解码值。如有任何关于如何修改以下全局预约 ID 代码的建议,我们将不胜感激:

var oPA = appt.PropertyAccessor;

//Get EntryId Value
var entryIDProperty = "http://schemas.microsoft.com/mapi/proptag/0x0FFF0102";
var entryId= oPA.BinaryToString(oPA.GetProperty(entryIDProperty));

//Now how to get the Global Appointment ID??
var globalApptProperty = http://schemas.microsoft.com/mapi/proptag/0x????????";
var globalId= oPA.BinaryToString(oPA.GetProperty(globalApptProperty ));
               

提前致谢。

解决方案

我意识到这可能不是实现目标的最佳方式,但它确实有效,所以我发帖以防它帮助其他人:

var item = Item as Outlook.MeetingItem;
var appt = item.GetAssociatedAppointment(false);              
var oPA = appt.PropertyAccessor;
                
//This parses the Global Appointment ID to a byte array. We need to retrieve    the "UID" from it (if available).
byte[] bytes = (byte[]) oPA.StringToBinary(appt.GlobalAppointmentID);

//According to https://msdn.microsoft.com/en-us/library/ee157690(v=exchg.80).aspx we don't need first 40 bytes            
if (bytes.Length>=40)
{                    
   byte[] bytesThatContainData = new byte[bytes.Length - 40];
   Array.Copy(bytes, 40, bytesThatContainData, 0, bytesThatContainData.Length);

   //In some cases, there won't be a UID.
   var test = Encoding.UTF8.GetString(bytesThatContainData, 0, bytesThatContainData.Length);

   if (test.StartsWith("vCal-Uid"))
   {
      //remove vCal-Uid from start string and special symbols
      test = test.Replace("vCal-Uid", string.Empty);
      test = test.Replace("\u0001", string.Empty);
      test = test.Replace("\0", string.Empty);

      //Here is the result
      var uid = test;
    }else{
      // Bad format!!!
    }
 }

【问题讨论】:

    标签: c# vsto outlook-addin mapi


    【解决方案1】:

    您可以从 AppointmentItem.GlobalAppointmentID 属性中提取它。其格式记录在https://msdn.microsoft.com/en-us/library/ee157690(v=exchg.80).aspx。如果数据部分以“vCal-Uid”开头,则 UID 紧随其后。

    【讨论】:

    • 谢谢,但是当我访问 GlobalAppointmentId 属性(放置用户接受会议请求时触发的断点)时,它实际上是一个不同的、更长的字符串。这实际上是我提出问题的最初原因,我们正在尝试通过通用 ID 同步在线创建的会议和在 Outlook 中创建的会议。
    • 例如,在原始的UID被邀请“augkaa383mj7v641rdikluit70@google.com”,但在Outlook对象全球预约ID为“040000008200E00074C5B7101A82E0080000000000000000000000000000000000000000320000007643616C2D556964010000006175676B61613338336D6A37763634317264696B6C756974373040676F6F676C652E636F6D00”。再次感谢。
    • 是的,正如我之前提到的,UID 嵌入在该二进制属性中。你需要解析它。使用 OutlookSpy 查看数据 - 单击 IMessage 按钮,选择 GlobalObjectId 属性,单击 Value 属性旁边的“...”按钮。
    • 好的,我明白了,谢谢!我已经安装了 OutlookSpy,现在将尝试。
    • 它在那里,谢谢!现在弄清楚如何在 C# 中抓取它。 . .
    猜你喜欢
    • 2021-11-22
    • 2020-09-25
    • 1970-01-01
    • 1970-01-01
    • 2011-01-07
    • 2012-01-22
    • 2011-09-13
    • 1970-01-01
    • 2011-03-06
    相关资源
    最近更新 更多