根据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>
答案 0 :(得分:0)
这可能吗?如果是这样,怎么能实现这个目标呢?
不,这是不可能的。 Office.js API加载项的设计是必需的用户调用。对于Outlook加载项,您可以使用"pinnable" taskpane功能在用户从消息切换到消息时保持加载项打开,但这与撰写无关,并且无论如何必须由用户在开始时启动。