Skip to content

New Outlook for Windows & OWA - Can't add internetHeaders back after removing #6389

@alexm-plutoflume

Description

@alexm-plutoflume

Provide required information needed to triage your issue

In New Outlook for Windows & OWA, it seems if you remove an internetHeader using the Office JS API, you are unable to add the header back. This is not the case in Classic Outlook for Windows or Mac.

Some of our workflows with our Smart Alerts OnMessageSend Add-in require us to remove stale headers at the start of a new send event, and potentially add them back before we allow the email to be sent. This bug breaks that flow.

Your Environment

  • Platform [PC desktop, Mac, iOS, Office on the web]: OWA & PC
  • Host [Excel, Word, PowerPoint, etc.]: New Outlook for Windows & OWA
  • Office version number: New Outlook for Windows
Image
  • Operating System: Windows 11 Pro 64-bit (10.0, Build 26100)
  • Browser (if using Office on the web): Chrome Version 143.0.7499.170 (Official Build) (arm64)

Expected behavior

I would expect headers removed with the internet headers api to be able to be added back to the email without restriction.

Current behavior

If you remove a header from the email, you cannot add it back. The add header API doesn't fail or anything, it just silently does not add the header back.

Steps to reproduce

  1. Add a header to an email using the internet headers api
  2. Remove the same header
  3. Try adding it back again
  4. Send the email and note the header is not on the email

Link to live example(s)

This code snippet replicates the issue

export const setInternetHeaderPropertyAsync = (headers: Record<string, string>): Promise<void> => {
  return new Promise<void>((resolve, reject) => {
    Office.context.mailbox.item?.internetHeaders.setAsync(headers, (asyncResult: Office.AsyncResult<void>) => {
      if (asyncResult.status === Office.AsyncResultStatus.Failed) {
        reject(asyncResult.error);
      } else {
        resolve();
      }
    });
  });
};

export const removeInternetHeadersAsync = (headers: string[]): Promise<void> => {
  return new Promise<void>((resolve, reject) => {
    Office.context.mailbox.item?.internetHeaders.removeAsync(headers, (asyncResult: Office.AsyncResult<void>) => {
      if (asyncResult.status === Office.AsyncResultStatus.Failed) {
        reject(asyncResult.error);
      } else {
        resolve();
      }
    });
  });
};

const onMessageSendHandlerImpl = async (event: Office.MailboxEvent) => {
  try {
    await setInternetHeaderPropertyAsync({ ["x-test-header"]: "true" });
    await removeInternetHeadersAsync(["x-test-header"]);
    await setInternetHeaderPropertyAsync({ ["x-test-header"]: "true" });
  } catch (e) {
    // No errors are thrown
    console.log(e);
  } finally {
    // Let email send and note that the header is not added to the email
    event.completed({ allowEvent: true });
  }
};

Provide additional details




Context

Some of our workflows with our Smart Alerts OnMessageSend Add-in require us to remove stale headers at the start of a new send event, and potentially add them back before we allow the email to be sent. This bug breaks that flow.

Useful logs

  • Console errors
  • Screenshots
  • Test file (if only happens on a particular file)

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions