Outlook插件在使用ItemSend时如何访问电子邮件的itemId。

huangapple go评论63阅读模式
英文:

Outlook Add-in how do i access the itemId of an email when using ItemSend

问题

我正在创建我的第一个Outlook附加组件,需要能够在发送邮件时获取邮件的itemID。

我在清单中设置了一个扩展点,当发送邮件时触发。被调用的函数用于保存邮件以获取itemID。然而,saveAsync返回的itemID与已发送邮件在"已发送"文件夹中的itemID不同。

经过一些研究,我发现saveAsync只返回一个临时的itemID,当邮件被发送并移动到"已发送"文件夹时会发生变化。

所以问题是如何获取已发送邮件的itemID?是否有更好的方法,或者是我漏掉了什么?

<ExtensionPoint xsi:type="Events">
<Event Type="ItemSend" FunctionExecution="synchronous" FunctionName="onEmailOrEventSend" />
</ExtensionPoint>
function onEmailOrEventSend(event) {
    mailboxItem.saveAsync({ asyncContext: event }, (results) => {
        if (results.error) {
            console.error("失败");
        } else {
           console.log("已保存!!! " + results.value);
            results.asyncContext.completed({ allowEvent: true });
        }
    });
}

我尝试在邮件保存之前获取itemID,但这并不起作用。

英文:

I am creating my first Outlook Add-in and i need to be able to get the itemID of an email when it is sent.

I have setup a ExtensionPoint in the manifest which is being triggered when an email is sent. The function being called is saving the email in order to get the itemID. However the itemID that is returned by saveAsync is different from the itemId of the sent email in the sent folder.

Doing some research I found out that saveAsync is only returning a temporary itemID which is changed when the email is sent and move to the Sent folder.

So the question is how do I get the itemId of the sent email ? is there a better way of doing this or am I missing something ?

&lt;ExtensionPoint xsi:type=&quot;Events&quot;&gt;
&lt;Event Type=&quot;ItemSend&quot; FunctionExecution=&quot;synchronous&quot; FunctionName=&quot;onEmailOrEventSend&quot; /&gt;
&lt;/ExtensionPoint&gt;
function onEmailOrEventSend(event) {
    mailboxItem.saveAsync({ asyncContext: event },(results) =&gt; {
        if (results.error) {
            console.error(&quot;Failed&quot;);
        } else {
           console.log(&quot;Saved!!!! &quot; + results.value);
            results.asyncContext.completed({ allowEvent: true });
        }
    });

I have tried to get the itemId before the email is saved but that does not work

答案1

得分: 0

itemId,类似于 COM 插件中的 EntryID,不是一个静态值。每当在 Exchange 中移动项目时,ID 将会改变。saveAsync 调用会将邮件保存到 草稿 文件夹中。当发送邮件时,项目首先移动到 发件箱,然后移动到 已发送项目 文件夹中。每次文件夹更改(草稿发件箱已发送项目)都会导致 itemId 字段的更改。EWS 文档 表明:

Exchange 中的标识符是不透明的。例如,EwsId 是从一些对开发人员不重要但对 Exchange 重要的信息中创建的。

在 Graph API 中,不可变标识符(IDs) 可能使您的应用程序获取一个在项目生命周期内不会更改的 ID。有关更多信息,请参阅获取 Outlook 资源的不可变标识符

英文:

The itemId, like the EntryID in COM add-ins, is not a static value. The ID will change whenever an item is moved around in Exchange. The saveAsync call results in the email being saved to the Drafts folder. When it is sent the item first moved to the Outbox and then into the Sent Items folder. Each of those folder changes (Drafts, Outbox, and Sent Items) results in a change to the itemId field. The EWS documentation states the following:

> Identifiers in Exchange are opaque. For example, the EwsId is created from several pieces of information that are not important to you as the developer, but are important to Exchange.

In Graph API Immutable identifiers (IDs) may enable your application to obtain an ID that does not change for the lifetime of the item. See Obtain immutable identifiers for Outlook resources for more information.

huangapple
  • 本文由 发表于 2023年3月1日 08:29:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75598577.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定