首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Outlook中触发console.log事件后如何实现ItemSend

在Outlook中触发console.log事件后如何实现ItemSend
EN

Stack Overflow用户
提问于 2022-03-16 15:11:44
回答 1查看 89关注 0票数 0

我在处理ItemSend事件时遇到了问题,这是因为functions外接程序提供了yo生成器,它使用webpack来捆绑代码,而不是暴露在全局范围内,然后是事件的必要功能。

清单中有正确的XML。

代码语言:javascript
运行
复制
<ExtensionPoint xsi:type="Events">
  <Event Type="ItemSend" FunctionExecution="synchronous" FunctionName="itemSendHandler" />
</ExtensionPoint>

itemSendHandler是全球性的,我的main.js是

代码语言:javascript
运行
复制
import { updateEventMetadataToServer, getUserCktId } from './cktApi.js'
import { initializeForm, fetchEventDataFromOutlook, fetchEventDataFromServer, setMsgOnFormConsole } from './form.js'
import { storeEventMetadata, loadEventMetadata, loadCustomProperty } from './outlookApi.js'

window.itemSendHandler = itemSendHandler 

test1 = 1 // for debug
function itemSendHandler (event) {
  fetchDataFromOutlookAndSubmitOrUpdateEventToCkt((err) => {
    if (err) {
      Office.context.mailbox.item.notificationMessages.replaceAsync('NoSend', { type: 'errorMessage', message: err.message })
      setTimeout(() => { event.completed({ allowEvent: false }) }, 3000)
    } else {
      const message = {
        type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
        message: 'Event submitted/updated to CKT' + test1,
        icon: 'Icon.80x80',
        persistent: true
      }
      Office.context.mailbox.item.notificationMessages.replaceAsync('action', message)
      setTimeout(() => { event.completed({ allowEvent: true }) }, 10000)
    }
  })
}

function fetchDataFromOutlookAndSubmitOrUpdateEventToCkt (_callback) {
  const callback = (err) => {
    if (typeof _callback === 'function') {
      _callback(err)
    }
  }

  fetchEventDataFromOutlook((err) => {
    if (err) {
      console.error('There was some error fetching data from Outlook:', err)
      callback(Error('There was some error fetching data from Outlook to CKT Addin'))
    } else {
      console.success('Data fetched from Outlook assigned to form')
      test1 = 20
      loadEventMetadata((metadata) => {
        console.log('METADATA loded from Outlook: ', metadata)
        test1 = JSON.stringify(metadata) + ''
        submitUpdateEvent(metadata, (err) => {
          if (err) {
            console.error('There was an error on submitUpdateEvent', err)
            callback(Error('There was some error submitting/updating the event to CKT server'))
          } else {
            console.success('Data submited/updated to server')
            callback()
          }
        })
      })
    }
  })
}

  • 知道在单击“发送”按钮后如何在边缘/webview2DEV控制台中使用console.log吗?我不能简单地调试,因为单击“发送”按钮后,就不会显示console.log。我很想在Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage上调试,这很奇怪,
  • ,知道为什么loadEventMetadata在正常情况下获取metadata,但是当itemSend被触发时失败吗?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-18 01:55:03

看一下这个文档:https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/debug-autolaunch

这实际上不是您的场景,但同样的regkey工作。(确保在您的外接程序id周围不包含"{}“。因此,设置以下regkey:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\WEF\Developer\5283AFBB-806E-2D05-BBAF-EF3384D30022

用您自己的外接程序ID替换GUID。

在该键单元中,设置一个UseDirectDebugger = 1的DWORD。

当您的外接程序启动时(任务窗格、执行函数、itemsend等)您应该得到一个如下所示的对话框:

从这里,您可以将调试器附加到WebView并调试外接程序,然后单击Ok。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71499566

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档