【问题标题】:outlook addin notification messageOutlook 插件通知消息
【发布时间】:2019-04-16 09:21:09
【问题描述】:

我想开发一个简单的 Outlook 插件,在发送电子邮件之前显示确认消息。 出于某种原因,它只显示默认错误消息“插件 xxx 正在阻止发送此电子邮件”。 此外,即使我允许事件完成,它也不允许我发送。

manifest.xml

  <Permissions>ReadWriteMailbox</Permissions>

  <Rule xsi:type="RuleCollection" Mode="Or">
    <Rule xsi:type="ItemIs" ItemType="Appointment" FormType="Edit" />
  </Rule>

  <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
    <!-- On Send requires VersionOverridesV1_1 -->
    <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1">
      <Description resid="residAppDescription" />
      <Requirements>
        <bt:Sets DefaultMinVersion="1.3">
          <bt:Set Name="Mailbox" />
        </bt:Sets>
      </Requirements>
      <Hosts>
        <Host xsi:type="MailHost">
          <DesktopFormFactor>
            <!-- The functionfile and function name to call on message send.  -->
            <!-- In this particular case the function calculateCostAndWarn will be called within the JavaScript code referenced in residUILessFunctionFileUrl. -->
            <FunctionFile resid="residUILessFunctionFileUrl" />
            <ExtensionPoint xsi:type="Events">
              <Event Type="ItemSend" FunctionExecution="synchronous" FunctionName="calculateCostAndWarn" />
            </ExtensionPoint>
          </DesktopFormFactor>
        </Host>
      </Hosts>
      <Resources>
        <bt:Urls>
          <!-- The JavaScript code is hosted on a secure and trusted web server. -->
          <bt:Url id="residUILessFunctionFileUrl" DefaultValue="https://localhost:3000/index.html" ></bt:Url>
        </bt:Urls>
      </Resources>
    </VersionOverrides>
  </VersionOverrides>

index.js

var mailboxItem;

Office.initialize = function (reason) {
    mailboxItem = Office.context.mailbox.item;
}

// Entry point for add-in before send is allowed.
function calculateCostAndWarn(event) {
	mailboxItem.notificationMessages.addAsync("information", {
	    type: "informationalMessage",
	    message : "The add-in processed this message.",
	    icon : "iconid",
	    persistent: false
	});
	event.completed({ allowEvent: true });
}

【问题讨论】:

  • 您可以尝试在调用 calculateCostAndWarn() 时将一些有用的信息记录到控制台吗?我只是想排除一种可能性,即发送操作被阻止,因为加载项未正确加载/加载时出现错误。
  • 我把 console.log("initialize");在 Office.initialize 和 console.log("event catch") 中;在计算成本和警告中。在 Chrome 控制台中,它显示“初始化”,但不显示“事件捕获”
  • 愚蠢的错误,index.html中对index.js的引用是错误的。

标签: node.js api events outlook-addin office-js


【解决方案1】:

愚蠢的错误,index.html中对index.js的引用是错误的

【讨论】:

    猜你喜欢
    • 2010-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-23
    • 1970-01-01
    • 2014-11-24
    • 2017-03-15
    • 1970-01-01
    相关资源
    最近更新 更多