【问题标题】:Get SingleValueExtendedProperties in outlook Add-In (js) which set through Office/Graph API?在通过 Office/Graph API 设置的 Outlook 加载项 (js) 中获取 SingleValueExtendedProperties?
【发布时间】:2017-05-23 13:13:26
【问题描述】:

My question is just opposite to scenario asked here

我们如何获取通过图形 API 设置的 SingleValueExtendedProperties,然后想在 office 插件中检索相同的属性。

设置:在下面编写类似的代码

var requestBody = new HttpRequestMessage(action, requestUrl) { Content = new StringContent("{'SingleValueExtendedProperties': [{'PropertyId':'String {66f5a359-4659-4830-9070-00047ec6ac6e} Name Color','Value':'Green'}]}", Encoding.UTF8, "application/json") };

阅读:我尝试使用所有组合来获取属性值但得到未定义的结果

    const item = Office.context.mailbox.item;
    item.loadCustomPropertiesAsync((result) => {
        const props = result.value;
        const testProp = props.get("Color");
        console.log("Color", testProp);
    });

谁能帮我在 office 365 插件中获取房产价值。

【问题讨论】:

    标签: javascript c# office365


    【解决方案1】:

    您将无法按照您尝试的方式读取属性,因为您创建的属性与 Mail App 格式不兼容,例如这在 https://msdn.microsoft.com/en-us/library/hh968549(v=exchg.80).aspx 中有记录(基本上属性本身包含应用程序的 ClientId它们属于,因此当您调用 loadCustomPropertiesAsync 时,它知道要获取哪些属性)。您在 Graph API 中使用的方法只是创建了一个普通的命名属性 https://msdn.microsoft.com/en-us/library/office/ff960427.aspx 。您可以在邮件应用程序中获取此属性,但只能使用 EWS(例如,您的应用程序需要 ReadItem 权限)并使用 makeEwsRequestAsync 发出 GetItem 请求。或者,您应该能够让 Graph API 以 MailApp 在 loadCustomPropertiesAsync 中读取的格式写入属性(如果您遵循文档,这需要编写多个属性)。

    补充

    如果您想在没有其他邮件应用设置属性的消息上使用 Graph API 设置属性,您会使用

    "SingleValueExtendedProperties": [
    {
    "PropertyId":"String 00020329-0000-0000-C000-000000000046 Name cecp-propertyNames",
    "Value":"cecp-51248e59-f341-4b4a-a81a-a418f8d3b179;"
     }
    ,{
    "PropertyId":"String 00020329-0000-0000-C000-000000000046 Name cecp-51248e59-f341-4b4a-a81a-a418f8d3b179",
    "Value":"{\"mail_note\":\"Whats the point\"}"
     }
    ]
    }

    此示例中的 Guid 51248e59-f341-4b4a-a81a-a418f8d3b179 应该与您的 MailApps 清单文件中的 UUID 匹配,例如

    <OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:type="MailApp">
        <!-- Id is a unique UUID for the mail app -->
        <Id>51248e59-f341-4b4a-a81a-a418f8d3b179</Id>

    如果其他 Mail 应用程序已在 Message 上设置属性,则您需要修改第一个属性以将 MailApp UUID 附加到该属性值中。例如,如果您的邮件应用程序 UUID 是 81a51297-e77e-4fae-a07f-af546013aeac 并且邮件已经具有上述值,您将修改属性,如

    “cecp-51248e59-f341-4b4a-a81a-a418f8d3b179;cecp-81a51297-e77e-4fae-a07f-af546013aeac;”

    【讨论】:

    • 谢谢! @Glen,这是否意味着我可以在加载项中读取道具值,但需要更多努力才能在图形 API 中正确写入它?如果可能的话,你能详细说明一下吗?
    猜你喜欢
    • 2017-08-25
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 2021-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多