Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Office.context.mailbox.item.internetMessageId is empty #4425

Closed
johnthad opened this issue May 7, 2024 · 13 comments
Closed

Office.context.mailbox.item.internetMessageId is empty #4425

johnthad opened this issue May 7, 2024 · 13 comments
Assignees
Labels
Area: Outlook Issue related to Outlook add-ins Resolution: by design Issue is by design

Comments

@johnthad
Copy link

johnthad commented May 7, 2024

The internetMessageId field of an email message is empty on all platforms tested. This can be demonstrated with one minor modification to the Build your first Outlook add-in demo.

Your Environment

  • Platform: PC desktop, Mac, and web
  • Host: Windows, macOS, Chrome (macOS), Edge (Windows)
  • Office: Windows Outlook 1.2024.501.300 (Production); macOS Outlook 16.84.2 (24042814); Office.js 1.1.10
  • Operating System: Windows 10 and macOS Sonoma 14.4.1
  • Browser: Chrome on macOS, Edge on Windows 10

Expected behavior

After clicking Run, Subject: should display followed by an internetMessageId, ex. Subject: <a8bc2e87-248f-455a-b5c9-db8026d788cc@az.eastus.microsoft.com>

Current behavior

Only Subject: displays.

Steps to reproduce

  1. Create the Build your first Outlook add-in demo.
  2. In src/taskpane/taskpane.js, line 22, change item.subject to item.internetMessageId and save the file.
  3. Run npm start and load the add-in in Outlook via the manifest.xml
  4. Open any piece of email for reading then select Contoso Add-in -> Show Taskpane from the Outlook ribbon.
  5. Press Run in the task panel.

Context

Without the internetMessageId I do not know how an add-in can reliably tell a server side MS Graph app (written in Java) which message it should open for key indexing data and attachments (for a document management system).

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP label May 7, 2024
@exextoc exextoc added Needs: attention 👋 Waiting on Microsoft to provide feedback Area: Outlook Issue related to Outlook add-ins and removed Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP labels May 7, 2024
@exextoc exextoc self-assigned this May 7, 2024
@timwan10
Copy link

timwan10 commented May 10, 2024

I feel like something may be missing from these repro steps. (especially if it repros across all platforms) Can you try Script Lab (installable through the App Store) to make sure it works?

Is there anything special about the email or the account that you are testing with?

I was able to get it working in Classic Windows Outlook. (are you on "old" outlook or "new" outlook?)

image

$("#run").on("click", run);

function run() {
  console.log(Office.context.mailbox.item.internetMessageId);
}

@johnthad
Copy link
Author

Thank you. AFAIK, the Outlook versions are all "new." The macOS was installed a few weeks ago, the Windows version just last week. (I'm not concerned with "old" Outlook. That supports our old add-ins which have been in use for years.)

Since running the modified add-in demo, my Outlook inbox received another email (sent from out corporate mail server using Mozilla's Thunderbird on macOS Sonoma 14.4.1). The modified add in shows the Message-ID for that email, but on no others--two from GMail in a browser, one from microsoft-noreply@microsoft.som (about upcoming subscription renewal), nor one I sent this morning from macOS Mail v16.0 (3774.500.171.1.1) through our corporate mail server. Your ScriptLab sample works for all emails with macOS Outlook. I've tried to test it in with Outlook for web, but today the add-in will not load despite repeated attempts to clear cache, reload, restart the dev server, etc.

Since the modified add-in demo works in one email but not others, I still believe there is a problem with office.js. As for Outlook for web, my attempts using it with demos fail more often than work. I can't believe that it's truly ready for production. (At best, I find it nearly useless for development and testing.)

@timwan10
Copy link

I'm going to forward this issue to the Mac and OWA group.

For Script Lab not working in OWA please see this:

OfficeDev/script-lab#1037 (comment)

@mmanjaree-msft
Copy link

@johnthad We could not repro the issue in mac outlook and owa. In case scriptlab is not working, could you try executing this -console.log(Office.context.mailbox.item.internetMessageId) in console after switching to your add-in frame and check if you see internetMessageId for all types of mails you mentioned

@johnthad
Copy link
Author

johnthad commented May 14, 2024

@timwan10 - Thanks for the tip about disabling Third Party Storage Partitioning. ScriptLabs now loads for me in Chrome (BTW, it's a nice tool). Would disabling Third Party Storage Partitioning be a user requirement for other add-ins, should we ever write one? (Someone might consider a note about this in the docs. It's far more helpful than references to IE11.)

@mmanjaree-msft - The console trick works. Thanks. As for my code demo, below is my taskpane.js. You can see that it is word-for-word identical to the taskpane.js in the Outlook quick start except for changing item.subject to item.internetMessage. I'm at a loss to understand why this change works for only one out of five emails in my Outlook inbox on both the macOS client and Outlook Web in Chrome.

/*
 * Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
 * See LICENSE in the project root for license information.
 */

/* global document, Office */

Office.onReady((info) => {
  if (info.host === Office.HostType.Outlook) {
    document.getElementById("sideload-msg").style.display = "none";
    document.getElementById("app-body").style.display = "flex";
    document.getElementById("run").onclick = run;
  }
});

export async function run() {
  // Get a reference to the current message
  const item = Office.context.mailbox.item;

  // Write message property value to the task pane
  document.getElementById("item-subject").innerHTML = "<b>Subject:</b> <br/>" + item.internetMessageId;
}

@mmanjaree-msft
Copy link

@johnthad Just to confirm. With api call in console, you are able to get internetMessageId but with this sample addin you see a blank.
Could you check for any errors in console specially if item itself is undefined. Close the taskpane and open and see if it works. Also share a repro video if possible

@anjalitp anjalitp added Needs: author feedback Waiting for author (creator) of Issue to provide more info and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels May 20, 2024
@johnthad
Copy link
Author

The DevTools console in Chrome is simple awash with red when I run Outlook in the browser. I've attached a log for a session and do not find the word "undefined" in a text search. In this session I open Outlook in chrome and run the add-in against several emails in the Inbox. Only one email shows its internetMessageId.

outlook.office.com-1716213574272.log

A video matching the creation of this log is at https://www.dropbox.com/scl/fi/1tntcza5tfadwyuc2n2v4/Screen-Recording-2024-05-20-at-09.57.51.mov?rlkey=p993obmebji7dsp6qe5cu0lw8&st=jmhjz783&dl=0

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: attention 👋 Waiting on Microsoft to provide feedback and removed Needs: author feedback Waiting for author (creator) of Issue to provide more info labels May 20, 2024
@rajjha-msft
Copy link

Thank you for bringing this to our attention. Based on the information you've provided; it appears that the issue may not be related to the platform as it works fine when called from Dev-Tools console.
We kindly suggest that you review the add-in code and investigate why it may not be functioning as expected. Please note that our support is limited to Office-Js related issues. We appreciate your understanding and cooperation in this matter.

@rajjha-msft rajjha-msft added Resolution: by design Issue is by design and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels May 24, 2024
@johnthad
Copy link
Author

johnthad commented May 24, 2024

I have reviewed the add-in's code. Presumably, Microsoft has also reviewed the add-in's code since it's Microsoft's example. As stated when opening this issue, the example is the Build your first Outlook add-in using the Yeoman generator, and changing one word. It appears there are circumstances where office.js is not finding internetMessageId in emails although it exists. I'd like to understand what those circumstances, and what can be done as a workaround.

@anjalitp
Copy link
Collaborator

anjalitp commented May 28, 2024

@johnthad The issue here seems related to the format of the internetMessageId which is enclosed in <>. The value is being assumed as a HTML tag and hence, not being displayed in taskpane. Could you please try updating the js code as below and see if the id populates correctly.
document.getElementById("item-subject").innerText = "<b>Subject:</b> <br/>" + item.internetMessageId;

@johnthad
Copy link
Author

No change. The internetMessageID displays on only the same email as before.

I removed the HTML markup from around the word "Subject:", changing line #21 from

document.getElementById("item-subject").innerHTML = "<b>Subject:</b> <br/>" + item.internetMessageId;

to

document.getElementById("item-subject").innerHTML = "Subject: " + item.internetMessageId;

I launch macOS Outlook and reset the account. I can see that "Subject:" is no longer in bold face but the internetMessageID still displays on only the same email as before. It fails to appear elsewhere, including a new email received yesterday from microsoft-noreply@microsoft.com confirming the renewal of my Exchange Online (Plan 1) subscription.

@anjalitp
Copy link
Collaborator

@johnthad You just need to change "innerHTML" to "innerText" and keep the remaining code as it is. Could you please try that?

@johnthad
Copy link
Author

Success! That works. My apologies for missing the change to innerText before. It's still curious to me that it works in one place and not others, but this issue closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Outlook Issue related to Outlook add-ins Resolution: by design Issue is by design
Projects
None yet
Development

No branches or pull requests

6 participants