Office-js: Windows Outlook: internetHeaders.setAsync being ignored in on-send hook

Created on 21 Sep 2020  路  9Comments  路  Source: OfficeDev/office-js

When you have a function file that processes a message during the send event any attempt to set internet headers during this window, specifically on Outlook for Windows, seems to result in a success from Office.js, in so much that no error is return in the async result, but when the recipient inspects the message headers, the specified header is not there.

Setting headers from a taskpane works as expected and these are present on the message in the recipients mailbox.

We have also tried to set headers directly on the message through the use of the Outlook REST API and a single value extended property call using the associated MAPI ID and desired name for the header and whilst this also returns as successful, the header, again, is not persisted after the send event completes. The code for this approach has been omitted from the sample repo for the sake of conciseness and keeping it focused on the APIs Office.js exposes to us but after looking at the calls Office.js is making in OWA, the setAsync method just seems to be a nice wrapper around a MAPI call anyway.

Expected Behavior

Headers that are set during the send event processing will persist and be sent with the message once the event has completed.

Current Behavior

Calling the setAsync methods returns as successful but the header is not persisted when the message arrives in the recipients mailbox.

Calling saveAsync on the item after setting the header seems to make no difference as well.

When the same code is run in either OWA or Outlook for Mac, the headers are present as expected when the message arrives in the recipients mailbox.

Steps to Reproduce, or Live Example

https://github.com/jak-hammond/office-js-on-send/tree/message-headers

  • Additional details:

    1. Clone repo and install manifest

    2. Create a new message

    3. Open the taskpane and click Run

    4. Send the message

    5. Inspect the message properties; File -> Properties -> Internet Headers

    6. Find 'x-taskpane-header' and x-onsend-header'

Context

We run some checks when a message and based on our results, we set various message headers that can be used later on in a users mail flow, at present, this means we cannot support Windows Outlook users unless they are aware they need to open the taskpane first which is a subpar user experience and can interrupt their workflow, the on-send hook should be able to handle this all silently for each send.

Your Environment

  • Platform [PC desktop, Mac, iOS, Office on the web]: PC Desktop
  • Host [Excel, Word, PowerPoint, etc.]: Outlook
  • Office version number: Version 2008 (Build 13127.20408 Click-to-run) Current Channel
  • Operating System: Windows 10
  • Browser (if using Office on the web): Successful functionality can be seen in OWA using Chrome
Outlook fixed product bug

Most helpful comment

We have fixed the bug and the fix should be available in build 16.0.13530.20004 or later. When an updated build is available depends on the release channel a customer is on.

All 9 comments

We've been doing some more investigating this morning and there is some timing or sync issue at play here. We have been able to get it working sporadically by attempting to modify other aspects of the message, we experimented with modifying the subject or prepending an empty string to the start of the message;

Office.context.mailbox.item.body.prependAsync("", {
            coercionType: Office.CoercionType.Text
        }, (asyncResult: Office.AsyncResult<void>) => { });

That above code did result in the headers being present for a short time, but then it reverted back to the incorrect behavior of missing them out when sent, this has been committed to the reproduction repo. We also tried calling saveAsync() directly on the message but that seemed to make no difference neither did trying to add artificial delays in the send to allow a 'sync' to happen with setTimeout() calls.

After some more investigation from our QA Engineers today, it seems the issue is more prominent when creating a brand new message compose session, so far our testing has not been able to reproduce this issue when replying to or forwarding a message that a recipient might have received.

We have tried various other approaches to try and work around this issue but after a few successful cases using the provided snippet above, we have not been able to get a positive test pass for this issue when composing a new message.

Hopefully this will help with your investigation and reproductions.

We have found that this issue is caused by a release made on July 30th, specifically version 2007 (Build 13029.20308) Current Channel, prior to that the behavior was working as expected, everything after that date is exhibiting this issue, so it would seem something has regressed within Outlook itself.

@exextoc Any update here? Thx.

Thanks for reporting this issue regarding internetHeaders.setAsync in on-send. It has been put on our backlog. We unfortunately have no timelines to share at this point.
Internal tracking id: Office:4492614

We are facing the exact issue and is significantly affecting our addin product. Is there any temporary fix to pass along the headers?. Thanks in advance.

Also, from our tests, it looks like the headers work fine in OWA. It seems to only be an issue with the outlook desktop client.

@ArjunSureshKumar92 the only work around we have at the moment is using the task pane to send to set the headers for a new message.

We have fixed the bug and the fix should be available in build 16.0.13530.20004 or later. When an updated build is available depends on the release channel a customer is on.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jarch09 picture Jarch09  路  3Comments

jacobx1 picture jacobx1  路  4Comments

binarykitchen picture binarykitchen  路  5Comments

kushwahav picture kushwahav  路  3Comments

KantilalJadav picture KantilalJadav  路  4Comments