根据Microsoft's documentation的说法,当用户通过指定激活规则进入“撰写”模式时,您应该能够激活Outlook外接程序。
在我的载货单上,我有
<Rule xsi:type="ItemIs" ItemType="Message" FormType="Edit" /> 当您从应用程序栏启动外接程序时,这将在右侧打开一个任务窗格。但是,我希望它在撰写窗口打开而不是打开任务窗格时自动启动。
这个是可能的吗?如果是这样,如何才能做到这一点呢?
清单如下:
<?xml version="1.0" encoding="UTF-8"?>
<!--Created:cb85b80c-f585-40ff-8bfc-12ff4d0e34a9-->
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MailApp">
<Id>dedf4528-4a6e-443b-8763-4ec32c340240</Id>
<Version>1.0.0.0</Version>
<ProviderName>Contoso, Inc.</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="HelloWorld" />
<Description DefaultValue="HelloWorld"/>
<Hosts>
<Host Name="Mailbox" />
</Hosts>
<Requirements>
<Sets>
<Set Name="MailBox" MinVersion="1.1" />
</Sets>
</Requirements>
<FormSettings>
<Form xsi:type="ItemEdit">
<DesktopSettings>
<SourceLocation DefaultValue="https://l.recognizeapp.com:50000/outlook-addin"/>
</DesktopSettings>
</Form>
</FormSettings>
<Permissions>ReadWriteItem</Permissions>
<Rule xsi:type="ItemIs" ItemType="Message" FormType="Edit" />
<DisableEntityHighlighting>false</DisableEntityHighlighting>
</OfficeApp>下面是源位置:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<title></title>
</head>
<body>
<style>
html, body, #wrapper {
min-height: 100%;
height: 100%;
width: 100%;
min-width: 100%;
}
p {
font-family: arial, sans-serif;
font-size: 11px;
color: #888;
}
#wrapper {
opacity: 0;
-webkit-transition: .5s opacity linear;
transition: .5s opacity linear;
}
#wrapper.loaded {
opacity: 1;
}
#wrapper .inner {
text-align: center;
}
.recognize {
color: #1568A6;
font-weight: 600;
}
</style>
<div id="wrapper" style="display: flex; align-items: center; justify-content: center; height: 100%; min-height: 100%; width: 100%; min-width: 100%">
<div class="inner">
<img src="/assets/icons/outlook-progress.gif" alt="Loading Recognize">
<p>Loading <span class="recognize">Recognize</span></p>
</div>
</div>
<script src="//appsforoffice.microsoft.com/lib/1/hosted/office.js"></script>
<%= javascript_include_tag "outlook-load" %>
<script>
var item;
Office.initialize = function () {
item = Office.context.mailbox.item;
// Checks for the DOM to load using the jQuery ready function.
$(document).ready(function () {
// After the DOM is loaded, app-specific code can run.
// Insert data in the top of the body of the composed
// item.
prependItemBody();
});
}
// Get the body type of the composed item, and prepend data
// in the appropriate data type in the item body.
function prependItemBody() {
item.body.getTypeAsync(
function (result) {
if (result.status == Office.AsyncResultStatus.Failed){
write(asyncResult.error.message);
}
else {
// Successfully got the type of item body.
// Prepend data of the appropriate type in body.
if (result.value == Office.MailboxEnums.BodyType.Html) {
// Body is of HTML type.
// Specify HTML in the coercionType parameter
// of prependAsync.
item.body.prependAsync(
'<b>Greetings, '+Office.context.mailbox.userProfile.emailAddress+'</b>',
{ coercionType: Office.CoercionType.Html,
asyncContext: { var3: 1, var4: 2 } },
function (asyncResult) {
if (asyncResult.status ==
Office.AsyncResultStatus.Failed){
write(asyncResult.error.message);
}
else {
// Successfully prepended data in item body.
// Do whatever appropriate for your scenario,
// using the arguments var3 and var4 as applicable.
}
});
}
else {
// Body is of text type.
item.body.prependAsync(
'Greetings, '+Office.context.mailbox.userProfile.emailAddress+":",
{ coercionType: Office.CoercionType.Text,
asyncContext: { var3: 1, var4: 2 } },
function (asyncResult) {
if (asyncResult.status ==
Office.AsyncResultStatus.Failed){
write(asyncResult.error.message);
}
else {
// Successfully prepended data in item body.
// Do whatever appropriate for your scenario,
// using the arguments var3 and var4 as applicable.
}
});
}
}
});
}
// Writes to a div with id='message' on the page.
function write(message){
document.getElementById('message').innerText += message;
}
</script>
</body>
</html>发布于 2017-04-11 08:35:04
这是可能的吗?如果是这样,如何才能做到这一点呢?
不,这不可能。Office.js应用编程接口外接程序的设计是必需的用户调用。对于Outlook add-in,当用户从一个邮件切换到另一个邮件时,您可以使用"pinnable" taskpane功能使您的插件保持打开状态,但这与撰写无关,无论如何都必须在开始时由用户启动。
https://stackoverflow.com/questions/43332357
复制相似问题