Skip to content

internetHeaders.setAsync inside OnMessageSend is silently dropped when forwarding a calendar invite from the Calendar view #6791

Description

@samle-plutoflume

Your Environment

  • Platform: PC desktop (Classic Outlook for Windows)
  • Host: Outlook
  • Office version number: 16.0.20131.20090
  • Operating System: Windows 11 Pro
  • Browser: N/A

Expected behavior

When an OnMessageSend handler calls
Office.context.mailbox.item.internetHeaders.setAsync({ "x-some-header": "true" })
and the callback reports AsyncResultStatus.Succeeded, the header is
present on the delivered message.

Current behavior

When the item being sent is a calendar-invite forward originated from
the Calendar view
(right-click event → Forward), the header is absent
from the delivered .eml, despite:

  • setAsync callback returning Succeeded
  • a follow-up getAsync in the same handler returning the value

The same handler code works correctly for new mail.

Steps to reproduce

  1. Switch to Calendar.
  2. Right-click an existing event → Forward.
  3. Address it to a mailbox you control and click Send.
  4. Inspect the delivered message's internet headers - x-min-repro-checked
    is missing.

Handler code:

var TAG = "[MIN-REPRO]";
var HEADER_NAME = "x-min-repro-checked";

console.log(TAG, "runtime script loaded");
console.log(TAG, "typeof Office =", typeof Office);
console.log(TAG, "typeof Office.actions =", typeof Office !== "undefined" && typeof Office.actions);

try {
  Office.actions.associate("onMessageSendHandler", onMessageSendHandler);
  console.log(TAG, "associate('onMessageSendHandler', ...) returned");
} catch (e) {
  console.log(TAG, "associate threw:", e && e.message);
}

function onMessageSendHandler(event) {
  console.log(TAG, "onMessageSendHandler invoked");

  var item = Office.context.mailbox.item;

  console.log(TAG, "setAsync", HEADER_NAME, "= true");
  var headersToSet = {};
  headersToSet[HEADER_NAME] = "true";
  item.internetHeaders.setAsync(headersToSet, function (setResult) {
    console.log(TAG, "setAsync status =", setResult.status);
    if (setResult.error) {
      console.log(TAG, "setAsync error", setResult.error.code, setResult.error.message);
    }

    console.log(TAG, "verify with getAsync");
    item.internetHeaders.getAsync([HEADER_NAME], function (getResult) {
      console.log(TAG, "getAsync status =", getResult.status);
      console.log(TAG, "getAsync value =", JSON.stringify(getResult.value));

      console.log(TAG, "event.completed allowEvent=true");
      event.completed({ allowEvent: true });
    });
  });
}

The handler does only:

  • internetHeaders.setAsync({ "x-min-repro-checked": "true" })
  • internetHeaders.getAsync(["x-min-repro-checked"]) to verify
  • event.completed({ allowEvent: true })

Useful logs

  • Console output

Runtime trace from the failing path:

'[MIN-REPRO]', 'onMessageSendHandler invoked'
'[MIN-REPRO]', 'setAsync', 'x-min-repro-checked', '= true'
'[MIN-REPRO]', 'setAsync status =', 'succeeded'
'[MIN-REPRO]', 'verify with getAsync'
'[MIN-REPRO]', 'getAsync status =', 'succeeded'
'[MIN-REPRO]', 'getAsync value =', '{"x-min-repro-checked":"true"}'
'[MIN-REPRO]', 'event.completed allowEvent=true'

Additionally, we noticed that the item type was reported as MESSAGE, not APPOINTMENT. Is this expected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions