Coder Social home page Coder Social logo

I have developed an outlook add-in. It is working fine in web version. But not working in desktop outlook app. about office-js HOT 17 CLOSED

prasath-pc avatar prasath-pc commented on August 10, 2024
I have developed an outlook add-in. It is working fine in web version. But not working in desktop outlook app.

from office-js.

Comments (17)

ElizabethSamuel-MSFT avatar ElizabethSamuel-MSFT commented on August 10, 2024

@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.

Let us know whether or not this unblocks you.

Thanks.

from office-js.

prasath-pc avatar prasath-pc commented on August 10, 2024

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.

ElizabethSamuel-MSFT avatar ElizabethSamuel-MSFT commented on August 10, 2024

@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.

Let us know how this goes for you.

Thanks.

from office-js.

prasath-pc avatar prasath-pc commented on August 10, 2024

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) {

})

image

from office-js.

prasath-pc avatar prasath-pc commented on August 10, 2024

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.

ElizabethSamuel-MSFT avatar ElizabethSamuel-MSFT commented on August 10, 2024

@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.

from office-js.

prasath-pc avatar prasath-pc commented on August 10, 2024

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.

prasath-pc avatar prasath-pc commented on August 10, 2024

image
image
Getting the error like this

from office-js.

ElizabethSamuel-MSFT avatar ElizabethSamuel-MSFT commented on August 10, 2024

@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.

Additionally, see Handle OnMessageSend and OnAppointmentSend events in your Outlook add-in with Smart Alerts.

Thanks.

from office-js.

prasath-pc avatar prasath-pc commented on August 10, 2024

@ElizabethSamuel-MSFT I have added these associate and the handler functions in the taskpane.html file itself
image
image
image
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.

ElizabethSamuel-MSFT avatar ElizabethSamuel-MSFT commented on August 10, 2024

@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.

ElizabethSamuel-MSFT avatar ElizabethSamuel-MSFT commented on August 10, 2024

@prasath-pc Were you able to move the handler code into a .js file?

from office-js.

DanielHo4 avatar DanielHo4 commented on August 10, 2024

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.

ElizabethSamuel-MSFT avatar ElizabethSamuel-MSFT commented on August 10, 2024

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.

DanielHo4 avatar DanielHo4 commented on August 10, 2024

sure, I just wondering this is one of the reason causing bug

from office-js.

microsoft-github-policy-service avatar microsoft-github-policy-service commented on August 10, 2024

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.

microsoft-github-policy-service avatar microsoft-github-policy-service commented on August 10, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.