OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
648 stars 92 forks source link

Windows Outlook: internetHeaders.setAsync not set using task pane #3393

Closed janjaeschke closed 1 month ago

janjaeschke commented 1 year ago

PLEASE NOTE: The behaviour described here is exactly the same as what is described in a ticket from December 2020, here: https://github.com/OfficeDev/office-js/issues/1401 and November 2022: https://github.com/OfficeDev/office-js/issues/2952

Setting headers from a taskpane does not return an error but the recipient will not see the the desired headers. Conclusion: headers are not attached to the email.

Using OWA or the new preview version of Outlook on a desktop PC the headers are added properly.

Your Environment

Expected Behavior

Headers that are set will persist and be sent with the message.

Current behavior

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

When the same code is run in either OWA or the preview of the new Outllook for Windows, the headers are present as expected when the message arrives in the recipients mailbox.

Steps to reproduce

  1. Set a header using code like this using the taskpane (we are using a checkbox to set or remove the header):
    Office.context.mailbox.item!.internetHeaders.setAsync( 
    { 'X-FooBar': 'true' }, 
    result => { 
        if (result.status === Office.AsyncResultStatus.Succeeded) { 
            const value = result.value; console.log(value);
        } else { 
            throw result.error; 
        }
    }
    )
  2. Check the header using the console:
    Office.context.mailbox.item.internetHeaders.getAsync(
        ['X-FooBar'],
        (x) => {console.log(x);}
    );
  3. Send the mail and check if the header is included in the recipients mailbox.

Context

We developed an add-in for our product to provide some features through Outlook. The add-in will change the behavior of the email processing using specific mail headers. It is impossible for us to support users with the original Outlook application unless the issue is resolved.

Useful logs

An example of the live add-in, checking the header before it should be set and afterwards:

image
DanilKorotenko commented 11 months ago

The same for Outlook for Mac. Here is my sample repository for more info: https://github.com/DanilKorotenko/OutlookAddinSetInternetHeaders

exextoc commented 10 months ago

@DanilKorotenko , to retrieve the internet headers on the received email in the recipients mailbox, you can use Office.context.mailbox.item.getAllInternetHeadersAsync. This will give all the internet headers on the item, and then you can check to see if yours was preserved or not.

More documentation about this API can be found here: https://learn.microsoft.com/en-us/javascript/api/outlook/office.messageread?view=outlook-js-preview#outlook-office-messageread-getallinternetheadersasync-member(1)

Are you saying that your add-in is calling Office.context.mailbox.item.getAllInternetHeadersAsync but the async result doesn't contain your header? I checked your add-in's source code, thanks for sharing the link. I couldn't find any calls to this API, so maybe that's the missing piece here?

janjaeschke commented 10 months ago

@exextoc due to the "Needs: author feedback" tag I like to redirect the topic in the original direction.

We are able to see the header while preparing the email, it is just missing on the recipients side which from our part is check on the third party recipients email server. The incoming email was dumped without any changes.

Edit: During my reply I noticed that the tag change was automatic, sorry for my misunderstanding.

exextoc commented 10 months ago

@janjaeschke, my apologies. The previous reply was actually meant for you, not @DanilKorotenko.

To clarify further, are you saying that the headers are missing when the recipient's mailbox is on a third-party mail server, however, everything works as expected if the recipient's mailbox is using Microsoft Exchange?

Is this third-party mail server a publicly-available one that anyone can create a test mailbox for?

janjaeschke commented 10 months ago

@exextoc no worries about that.

No the header is never applied on an outbound email, even if I sent the email in the same O365 tenant using the local outlook client. It is always working if I use the OWA or the new web based Outlook client.

The third-party mail server is not publicly-available but I can 100% confirm that the server is not removing the header. It is managed by ourself.

exextoc commented 10 months ago

@janjaeschke, how are you retrieving the headers once the email has arrived in the recipient's Inbox? Are you using one of our APIs or are you inspecting the item some other way?

janjaeschke commented 10 months ago

@exextoc In case of my O365 recipient I used Outlook.com -> opened the message -> View -> View message details. For my local recipient I can dump the EML using the email server itself and I created a network trace while receiving it. In each case the header is missing.

DanilKorotenko commented 10 months ago

it is working now for me.

exextoc commented 10 months ago

Glad it is working for you now. If there's anything you did differently that potentially resulted in fixing this issue, please do so to help future readers of this post.

janjaeschke commented 10 months ago

@exextoc just to make sure: it is still not working on our side.

@DanilKorotenko did you change anything?

DanilKorotenko commented 10 months ago

@janjaeschke Actually, I thought that it was fixed on your side. Because, on my side, this issue is reproduced in Outlook for Mac 16.74 (23061100). And, it didn't reproduce in ver.: Outlook for Mac 16.74.1 (23061800)

DanilKorotenko commented 10 months ago

@janjaeschke For now, 16.75.2 (23072301), everything works perfect. Thank you.

DanilKorotenko commented 10 months ago

@janjaeschke I don't know the situation with Outlook for Windows, but for Mac, all works good.

janjaeschke commented 10 months ago

Thank you for the update.

I am currently at version: Microsoft® Outlook® für Microsoft 365 MSO (Version 2306 Build 16.0.16529.20164) 64 Bit on Windows and it is still not working.

exextoc commented 10 months ago

@janjaeschke, I just tried a more recent version of Microsoft Outlook. I composed an email from a test account in a Microsoft 365 tenant, added an internet header using Office.context.mailbox.item.internetHeaders.setAsync, then confirmed that the headers had been set with Office.context.mailbox.item.internetHeaders.getAsync, sent the email to a test account @outlook.com. When I inspect the email received by the test account @outlook.com, it correctly contains the headers I set during compose.

Step by step of my test:

  1. Create a new compose email using an account from my Microsoft 365 test tenant.
  2. Launched my taskpane addin, and then clicked on a button in the taskpane to add an internet header:
    Office.context.mailbox.item.internetHeaders.setAsync(
    { "key11" : "value11" },
    function (asyncResult) {
        console.log(JSON.stringify(asyncResult));
    }
    );
  3. Retrieved the internet header I just set to confirm that it was successfully set:
    Office.context.mailbox.item.internetHeaders.getAsync(
    [ "key11" ],
    function (asyncResult) {
        console.log(JSON.stringify(asyncResult));
    }
    );
  4. Sent the email to a test consumer account with @outlook.com domain.
  5. Switched Outlook to the test consumer account with @outlook.com domain.
  6. Opened the received email, and inspected the internet headers. Instructions for inspecting headers: https://support.microsoft.com/en-au/office/view-internet-message-headers-in-outlook-cd039382-dc6e-4264-ac74-c048563d212c
  7. As expected, I found key11: value11 in the list of headers.

Is there anything significantly different from my repro steps and yours?

janjaeschke commented 9 months ago

@exextoc Yes the difference seems to be the header name. I used your steps, which are identical to ours, to make sure the issue still exists in my current Outlook version. While testing the steps I also tried your header name "key11" and this was working fine. So I played around and it looks like that just the name of our header has the issue:

Office.context.mailbox.item.internetHeaders.setAsync(
    { "X-NoSpamProxy-RequireAttachmentPassword" : "true" },
    function (asyncResult) {
        console.log(JSON.stringify(asyncResult));
    }
);

Sets the header and the getAsync returns it but the delivered email does not include the header. To be really sure that my tenant does not have any strange configuration I used a new one where exchange online was never touched before and the issue was reproducible.

Please check if it is the same in your environment.

exextoc commented 9 months ago

@janjaeschke, I just checked my environment. I used both Outlook.com and my test tenant, and your code works perfectly for me. The received emails also contain your header. Below is a screenshot.

image

I just created a fresh test tenant, tried your code, and it worked as expected. The received email contains the X-NoSpamProxy-RequireAttachmentPassword header key with a value of "true".

Do you mind creating a test account for me to use to reproduce this issue? You can create a private GitHub repository and @-mention exextoc so that I can access it for the details.

janjaeschke commented 9 months ago

@exextoc as mentioned in the opening message Outlook.com and the new web based Outlook is working fine. The issue only occurs with the normal outlook client on you windows PC.

Just add our Outlook.com account to the Outlook client and add the header again over the Viva Insights Add-In pane. As recipient you can use another user of the same O365 tenant.

The header should be missing

exextoc commented 9 months ago

@janjaeschke, I used the Windows Desktop Outlook client connected to an Outlook.com account and also to my test tenant. I understand that you are not referring to the web client since everything is working fine there. All my communications and validations have been about the Windows Desktop Outlook client.

microsoft-github-policy-service[bot] commented 9 months ago

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!

microsoft-github-policy-service[bot] commented 9 months ago

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!

janjaeschke commented 9 months ago

@exextoc thank you for the clarification.

I created a private repository (https://github.com/noSpamProxy/office-js-3393) with two accounts of my testing O365 tenant and the code I use through the console to add the header.

Please let me know if there is any issue accessing the repository.

exextoc commented 9 months ago

@janjaeschke, thanks for the private repository. Using my own test add-in, I set the headers specified in your private repo's README file. I tried both sending the email to the same account and then sending from one account to the other, as you mentioned in your README file. Both of them worked successfully. The internet headers were present in both cases.

Can you check the recipient's Inbox (using the Desktop Outlook client) for an email titled "test with X-NoSpamProxy-RequireAttachmentPassword to Grady" and inspect it to see if your header is present?

Below is a screenshot with all internet headers cropped out except yours: image

janjaeschke commented 9 months ago

@exextoc thank you for testing it out.

I can see your email and I can confirm that the header is present. It makes me clueless that we are running into this issue and you are not... Are you using a later Outlook version or do you have any other idea how to analyse this further?

exextoc commented 9 months ago

@janjaeschke, yes, I'm using a newer version of Outlook. My version is a pre-release of 2308, so not very far off from your highest version number of 2307 that you mentioned in the private repository.

It seems you are able to reproduce this issue with 2304 and 2307. If that's accurate, kindly let me know. I'm going to try out your test accounts with 2307.

janjaeschke commented 9 months ago

@exextoc yes your assumption is correct.

I am running 2307 as daily driver and the issue is reproducible every time with it.

janjaeschke commented 9 months ago

@exextoc any updates on this topic?

exextoc commented 8 months ago

Can we connect offline to look into this further? Please create a private repo, place your email address in there, and then at-mention me and I will connect with you offline to discuss further. Alternatively, if you update your profile with your email address, I can grab it from your profile. Thanks.

janjaeschke commented 8 months ago

For sure we can talk offline about this. I updated the existing private repository with my email address: https://github.com/noSpamProxy/office-js-3393 You should still have access to it.

henning-krause commented 7 months ago

@exextoc Do you have an update here?

janjaeschke commented 6 months ago

@exextoc any news here? I still did not receive an email :(

exextoc commented 6 months ago

@janjaeschke, apologies for the delay here. The private repository you created earlier on is no longer available. Please create another one with your contact information and then I will email you. The email user will be a test account named DebraB, so please check your spam folder if you haven't received the email after I confirm sending it. Thanks.

henning-krause commented 6 months ago

Hi @exextoc. I'm taking over for my colleague Jan for the moment.

You should already have access to the repo: image

henning-krause commented 5 months ago

@exextoc Anything new on this case?

janjaeschke commented 4 months ago

@exextoc I am a bit surprised you didn't had access anymore. Was Hennings help useful? How can we process further in this topic?

We need to find any kind of a solution for this, the new Outlook seems to become more popular and it is impossible for us to support this platform with good feelings.

henning-krause commented 3 months ago

@exextoc Any news on this case?

janjaeschke commented 1 month ago

Due to the age and missing responses I tried to reproduce this issue nearly 1 year later. I wasn't able to reproduce it anymore and hope it is fixed by an Outlook version update which might be delivered to the most customers.

Issue closed.