英文:
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 ?
<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("Failed");
} else {
console.log("Saved!!!! " + 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论