Comments (17)
@prasath-pc Thanks for asking about this.
There's a new version of Outlook on Windows that's currently in preview. It seems like you're not using that version but the classic version that's currently generally available to customers.
For this to work in classic Outlook on Windows, you must include a JavaScript override in the Runtime node. That section of your XML manifest should look something like the following:
<Runtimes>
<!-- HTML file including reference to or inline JavaScript event handlers.
This is used by Outlook on the web and on the new Mac UI, and new Outlook on Windows (preview). -->
<Runtime resid="WebViewRuntime.Url">
<!-- JavaScript file containing event handlers. This is used by classic Outlook on Windows. -->
<Override type="javascript" resid="JSRuntime.Url"/>
</Runtime>
</Runtimes>
Your Resources -> Urls section should contain an associated entry which maps to a .js file that contains all your event handling JavaScript. Maybe your taskpane.js is that file?
<!-- Entry needed for classic Outlook on Windows. -->
<bt:Url id="JSRuntime.Url" DefaultValue="https://demo.peppercloud.com/office365app/launchevent.js" />
If you haven't already seen this, you can learn more about this feature in the following articles.
- Automatically check for an attachment before a message is sent
- Configure your Outlook add-in for event-based activation
Let us know whether or not this unblocks you.
Thanks.
from office-js.
Hi @ElizabethSamuel-MSFT The issue solved now. Here is my updated manifest.xml file.
But now I am facing issue in
Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function(result) {
})
error: OSF.DDA.Error
code: 9018
message: "An internal error has occurred."
name: "GenericTokenError
status: "failed"
value: undefined
Help me to fix this issue
Actually we have to log out email to the CRM. I am using the below code to call the API
```
function LogMailToCRM(event) {
let item = Office.context.mailbox.item;
item.saveAsync((res)=>{
item.getItemIdAsync((re)=>{
let it = Office.context.mailbox.item;
let itemId = re.value;
Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function(result) {
if (result.status === Office.AsyncResultStatus.Succeeded) {
var accessToken = result.value;
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://outlook.office.com/api/v2.0/me/messages/' + itemId + '/?$select=conversationId', true);
xhr.setRequestHeader('Authorization', 'Bearer ' + accessToken);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) {
var response = JSON.parse(xhr.responseText);
var conversationId = response.ConversationId;
console.log("Conversation ID: ", conversationId);
onEmailSendHook(conversationId, event);
} else {
event.completed({ allowEvent: true });
}
};
xhr.onerror = function() {
console.error("Request failed");
event.completed({ allowEvent: true });
};
xhr.send();
} else {
console.error("Error getting callback token: ", result.error.message);
}
});
});
})
}
Once I get the token from the getCallbackTokenAsync, I have to call the another api https://outlook.office.com/api/v2.0/me/messages/' + itemId + '/?$select=conversationId', true
Help me solve this issue
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0" xsi:type="MailApp">
<Id>0a2c0a96-c046-42cf-8545-8228095caf17</Id>
<Version>1.0.0.0</Version>
<ProviderName>Pepper Cloud CRM</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="Pepper Cloud"/>
<Description DefaultValue=" "/>
<IconUrl DefaultValue="https://localhost:9000/images/chrome_logo.png"/>
<HighResolutionIconUrl DefaultValue="https://localhost:9000/images/pc-logo-128.png"/>
<SupportUrl DefaultValue="https://www.contoso.com/help"/>
<AppDomains>
<AppDomain>https://localhost:3000</AppDomain>
<AppDomain>https://demo.peppercloud.com</AppDomain>
<AppDomain>https://login.microsoftonline.com</AppDomain>
</AppDomains>
<Hosts>
<Host Name="Mailbox"/>
</Hosts>
<Requirements>
<Sets>
<Set Name="Mailbox" MinVersion="1.1"/>
</Sets>
</Requirements>
<FormSettings>
<Form xsi:type="ItemRead">
<DesktopSettings>
<SourceLocation DefaultValue="https://localhost:5000/taskpane.html"/>
<RequestedHeight>250</RequestedHeight>
</DesktopSettings>
</Form>
</FormSettings>
<Permissions>ReadWriteItem</Permissions>
<Rule xsi:type="RuleCollection" Mode="Or">
<Rule xsi:type="ItemIs" ItemType="Message" FormType="Read"/>
</Rule>
<DisableEntityHighlighting>false</DisableEntityHighlighting>
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1">
<Requirements>
<bt:Sets DefaultMinVersion="1.3">
<bt:Set Name="Mailbox"/>
</bt:Sets>
</Requirements>
<Hosts>
<Host xsi:type="MailHost">
<Runtimes>
<Runtime resid="WebViewRuntime.Url">
<Override type="javascript" resid="JSRuntime.Url"/>
</Runtime>
</Runtimes>
<DesktopFormFactor>
<FunctionFile resid="Taskpane.Url"/>
<ExtensionPoint xsi:type="LaunchEvent">
<LaunchEvents>
<LaunchEvent Type="OnMessageSend" FunctionName="LogMailToCRM" />
</LaunchEvents>
<SourceLocation resid="WebViewRuntime.Url"/>
</ExtensionPoint>
<ExtensionPoint xsi:type="MessageReadCommandSurface">
<OfficeTab id="TabDefault">
<Group id="msgReadGroup">
<Label resid="GroupLabel"/>
<Control xsi:type="Button" id="msgReadOpenPaneButton">
<Label resid="TaskpaneButton.Label"/>
<Supertip>
<Title resid="TaskpaneButton.Label"/>
<Description resid="TaskpaneButton.Tooltip"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<Action xsi:type="ShowTaskpane">
<SourceLocation resid="Taskpane.Url"/>
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
<ExtensionPoint xsi:type="MessageComposeCommandSurface">
<OfficeTab id="TabDefault">
<Group id="msgComposeGroup">
<Label resid="GroupLabel"/>
<Control xsi:type="Button" id="msgComposeOpenPaneButton">
<Label resid="TaskpaneButton.Label"/>
<Supertip>
<Title resid="TaskpaneButton.Label"/>
<Description resid="TaskpaneButton.Tooltip"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<Action xsi:type="ShowTaskpane">
<SourceLocation resid="Taskpane.Url"/>
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
</DesktopFormFactor>
</Host>
</Hosts>
<Resources>
<bt:Images>
<bt:Image id="Icon.16x16" DefaultValue="https://localhost:9000/images/logo.svg"/>
<bt:Image id="Icon.32x32" DefaultValue="https://localhost:9000/images/logo.svg"/>
<bt:Image id="Icon.80x80" DefaultValue="https://localhost:9000/images/logo.svg"/> </bt:Images>
<bt:Urls>
<bt:Url id="Commands.Url" DefaultValue="https://localhost:5000/commands.html"/>
<bt:Url id="Taskpane.Url" DefaultValue="https://localhost:5000/taskpane.html"/>
<bt:Url id="WebViewRuntime.Url" DefaultValue="https://localhost:5000/taskpane.html" />
<bt:Url id="JSRuntime.Url" DefaultValue="https://localhost:5000/taskpane.js" />
</bt:Urls>
<bt:ShortStrings>
<bt:String id="GroupLabel" DefaultValue="Pepper Cloud Add-in"/>
<bt:String id="TaskpaneButton.Label" DefaultValue="Show Taskpane"/>
<bt:String id="ActionButton.Label" DefaultValue="Perform an action"/>
</bt:ShortStrings>
<bt:LongStrings>
<bt:String id="TaskpaneButton.Tooltip" DefaultValue="Opens a pane displaying all available properties."/>
<bt:String id="ActionButton.Tooltip" DefaultValue="Perform an action when clicked."/>
</bt:LongStrings>
</Resources>
</VersionOverrides>
</VersionOverrides>
</OfficeApp>
from office-js.
@prasath-pc It looks like you're trying to call the Outlook REST APIs directly. The REST APIs are being deprecated and we're encouraging developers to call Outlook REST APIs through Microsoft Graph. For more about this, you can start with the following articles.
- Use the Outlook REST APIs from an Outlook add-in
- Compare Microsoft Graph and Outlook REST API endpoints - "Moving from Outlook endpoint to Microsoft Graph" section
Let us know how this goes for you.
Thanks.
from office-js.
Thanks @ElizabethSamuel-MSFT .
I understand that I have to use the graph API.
But why this function gives me an error ?
Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function(result) {
})
from office-js.
I will have to send the bearer token while I making calls to the graph APIs right ?
If yes then, in my addin, from where I can get the token ?
Help me on this,
Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function(result) {
})
I am trying the above function, but got the error.
from office-js.
@prasath-pc The example provided with the Mailbox.getCallbackTokenAsync API documentation may be helpful. (You can view and try out that example in Script Lab.) It looks like you're at least missing the conversion of the itemId from the default EWS ID version to REST ID.
The following are a couple of more comprehensive samples (but note the first 2 are archived) that may be helpful.
- Using REST: https://github.com/OfficeDev/outlook-add-in-command-demo
- Using Microsoft Graph: https://github.com/OfficeDev/Office-Add-in-samples/tree/main/Samples/Outlook.ConsumeGraphAPI
- Using SSO and Microsoft Graph: https://learn.microsoft.com/office/dev/add-ins/outlook/implement-sso-in-outlook-add-in
from office-js.
Thanks @ElizabethSamuel-MSFT , I am getting the token. I have given my updated manifest file. I am using <LaunchEvent Type="OnMessageSend" FunctionName="LogMailToCRM" />
.
This is working fine in web/Outlook dekstop (new). But not working in Outlook desktop (version 2403) that is comes with Microsoft 365 Personal
What could be the issue ?
Same manifest files are working fine in web/Outlook dekstop (new)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0" xsi:type="MailApp"> <Id>044fae4f-1e5c-41d4-b06d-3dad06275dfc</Id> <Version>1.0.0.0</Version> <ProviderName>Pepper Cloud CRM</ProviderName> <DefaultLocale>en-US</DefaultLocale> <DisplayName DefaultValue="Pepper Cloud"/> <Description DefaultValue=" "/> <IconUrl DefaultValue="https://demo.peppercloud.com/office365app/assets/chrome_logo.png"/> <HighResolutionIconUrl DefaultValue="https://demo.peppercloud.com/office365app/assets/pc-logo-128.png"/> <SupportUrl DefaultValue="https://peppercloud.com/contact"/> <AppDomains> <AppDomain>https://demo.peppercloud.com</AppDomain> <AppDomain>https://login.microsoftonline.com</AppDomain> </AppDomains> <Hosts> <Host Name="Mailbox"/> </Hosts> <Requirements> <Sets> <Set Name="Mailbox" MinVersion="1.1"/> </Sets> </Requirements> <FormSettings> <Form xsi:type="ItemRead"> <DesktopSettings> <SourceLocation DefaultValue="https://demo.peppercloud.com/office365app/taskpane.html"/> <RequestedHeight>250</RequestedHeight> </DesktopSettings> </Form> </FormSettings> <Permissions>ReadWriteItem</Permissions> <Rule xsi:type="RuleCollection" Mode="Or"> <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read"/> </Rule> <DisableEntityHighlighting>false</DisableEntityHighlighting> <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0"> <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1"> <Requirements> <bt:Sets DefaultMinVersion="1.3"> <bt:Set Name="Mailbox"/> </bt:Sets> </Requirements> <Hosts> <Host xsi:type="MailHost"> <Runtimes> <Runtime resid="WebViewRuntime.Url"> <Override type="javascript" resid="JSRuntime.Url"/> </Runtime> </Runtimes> <DesktopFormFactor> <FunctionFile resid="Taskpane.Url"/> <ExtensionPoint xsi:type="LaunchEvent"> <LaunchEvents> <LaunchEvent Type="OnMessageSend" FunctionName="LogMailToCRM" /> </LaunchEvents> <SourceLocation resid="WebViewRuntime.Url"/> </ExtensionPoint> <ExtensionPoint xsi:type="MessageReadCommandSurface"> <OfficeTab id="TabDefault"> <Group id="msgReadGroup"> <Label resid="GroupLabel"/> <Control xsi:type="Button" id="msgReadOpenPaneButton"> <Label resid="TaskpaneButton.Label"/> <Supertip> <Title resid="TaskpaneButton.Label"/> <Description resid="TaskpaneButton.Tooltip"/> </Supertip> <Icon> <bt:Image size="16" resid="Icon.16x16"/> <bt:Image size="32" resid="Icon.32x32"/> <bt:Image size="80" resid="Icon.80x80"/> </Icon> <Action xsi:type="ShowTaskpane"> <SourceLocation resid="Taskpane.Url"/> </Action> </Control> </Group> </OfficeTab> </ExtensionPoint> <ExtensionPoint xsi:type="MessageComposeCommandSurface"> <OfficeTab id="TabDefault"> <Group id="msgComposeGroup"> <Label resid="GroupLabel"/> <Control xsi:type="Button" id="msgComposeOpenPaneButton"> <Label resid="TaskpaneButton.Label"/> <Supertip> <Title resid="TaskpaneButton.Label"/> <Description resid="TaskpaneButton.Tooltip"/> </Supertip> <Icon> <bt:Image size="16" resid="Icon.16x16"/> <bt:Image size="32" resid="Icon.32x32"/> <bt:Image size="80" resid="Icon.80x80"/> </Icon> <Action xsi:type="ShowTaskpane"> <SourceLocation resid="Taskpane.Url"/> </Action> </Control> </Group> </OfficeTab> </ExtensionPoint> </DesktopFormFactor> </Host> </Hosts> <Resources> <bt:Images> <bt:Image id="Icon.16x16" DefaultValue="https://demo.peppercloud.com/office365app/assets/icon-16.png"/> <bt:Image id="Icon.32x32" DefaultValue="https://demo.peppercloud.com/office365app/assets/icon-32.png"/> <bt:Image id="Icon.80x80" DefaultValue="https://demo.peppercloud.com/office365app/assets/icon-80.png"/> </bt:Images> <bt:Urls> <bt:Url id="Commands.Url" DefaultValue="https://demo.peppercloud.com/office365app/commands.html"/> <bt:Url id="Taskpane.Url" DefaultValue="https://demo.peppercloud.com/office365app/taskpane.html"/> <bt:Url id="WebViewRuntime.Url" DefaultValue="https://demo.peppercloud.com/office365app/taskpane.html" /> <bt:Url id="JSRuntime.Url" DefaultValue="https://demo.peppercloud.com/office365app/taskpane.js" /> </bt:Urls> <bt:ShortStrings> <bt:String id="GroupLabel" DefaultValue="Pepper Cloud Add-in"/> <bt:String id="TaskpaneButton.Label" DefaultValue="Show Taskpane"/> <bt:String id="ActionButton.Label" DefaultValue="Perform an action"/> </bt:ShortStrings> <bt:LongStrings> <bt:String id="TaskpaneButton.Tooltip" DefaultValue="Opens a pane displaying all available properties."/> <bt:String id="ActionButton.Tooltip" DefaultValue="Perform an action when clicked."/> </bt:LongStrings> </Resources> </VersionOverrides> </VersionOverrides> </OfficeApp>
from office-js.
from office-js.
@prasath-pc In your .js file containing the event handling code, do you have the required associate
statement mapping the LaunchEvent FunctionName in the manifest with the actual function name in the .js file (even if they're the same)?
For examples, see the following samples.
- https://github.com/OfficeDev/Office-Add-in-samples/blob/main/Samples/outlook-verify-sensitivity-label/src/commands/commands.js
- https://github.com/OfficeDev/Office-Add-in-samples/blob/main/Samples/outlook-check-item-categories/src/commands/commands.js
Additionally, see Handle OnMessageSend and OnAppointmentSend events in your Outlook add-in with Smart Alerts.
Thanks.
from office-js.
@ElizabethSamuel-MSFT I have added these associate and the handler functions in the taskpane.html file itself
The thing is it is working fine in all other platforms right ?
It is not working on Microsoft 365 Outlook desktop version only
from office-js.
@prasath-pc Unfortunately, the handler code must be in a .js file for the classic Outlook on Windows to consume it. Same goes for the associate statement. These are requirements for classic Outlook on Windows desktop which looks to the Runtime Override .js location for the event handling code.
from office-js.
@prasath-pc Were you able to move the handler code into a .js file?
from office-js.
Hi all,
I am new to OfficeJS, and I just developed an Outlook plugin with an OnSend feature.
I found that the header of the HTTP request in the OnSend function in the classic desktop Outlook seems different from the web version of Outlook. The header sent by classic desktop Outlook is much larger than the web version causing the request to fail. Is there any explanation for the HTTP request header size is different when using classic desktop Outlook and web Outlook?
from office-js.
Hi all,
I am new to OfficeJS, and I just developed an Outlook plugin with an OnSend feature.
I found that the header of the HTTP request in the OnSend function in the classic desktop Outlook seems different from the web version of Outlook. The header sent by classic desktop Outlook is much larger than the web version causing the request to fail. Is there any explanation for the HTTP request header size is different when using classic desktop Outlook and web Outlook?
@DanielHo4 Can you create a new issue for your question? Then we can track it separately and assign as appropriate.
Thanks.
from office-js.
sure, I just wondering this is one of the reason causing bug
from office-js.
This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!
from office-js.
This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue.
from office-js.
Related Issues (20)
- Create Presentation/Excel API HOT 3
- Highlight custom tab on opening document HOT 12
- Trying to upload my add-in manifest no longer works HOT 17
- Outlook Exchange Online: When Plan to GA: Enable SSO in an Office Add-in using nested app authentication (preview) HOT 3
- HTML insertion in old Outlook desktop has incorrect fonts in tables
- Pinnable task panes do not stay pinned on refresh in modern Outlook web HOT 1
- Taskpane Button Menu validation based on option with SupportsMultiSelect enabled HOT 3
- Office.context.mailbox.item.displayReplyAllForm attachments fails in Outlook Web platform HOT 5
- Excel freezes and crashes upon opening a specific file HOT 4
- Addin is not loading HOT 5
- Outlook add-in is not opening for some users in new Outlook for Windows UI HOT 6
- Outlook: Register the online-meeting template for Meta Horizon Workrooms HOT 5
- Broken "Always remember my choice for this application" checkbox and "Open" button for Excel Add-in's warning dialog HOT 14
- How to dynamically switch between read-only and editing modes of documents through the Word JavaScript API HOT 5
- Office.auth.getAccessToken not supported in Outlook add-ins HOT 3
- The onMessageRecipientsChangedHandler event does not get executed completely in Mac HOT 6
- Smart Alert Feature not working in Outlook Mac Thick Client HOT 2
- range.getDirectDependents should return dependent cell that refer as table columns HOT 4
- Attachments intermittently become locked on a message and cannot be deleted or previewed in new outlook HOT 16
- How to get image using Shape getAsImage for Dynamic Images HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from office-js.