support folding headers according to RFC5322 for outlook add in
RFC 5322 (section 2.2.3) supports header folding so headers with more than 998 characters can be used in email.
unfortunately office-js doesn't support that and has a fixed maximum length of 998 which it seems to check with a simple check for string length.
If this check is removed, office-js doesn't complain but outlook itself (or the API of it) complains with either a formatting error 2006 (outlook 2016) or without any error (MS 365 with on prem exchange and outlook.office365.com)
Here is an example header
my-type="urn:my:test:which:is:longer:than:998:1:0"; my-param*0="PG1iOadpbmRpbmdJbmZvcm1hdGlvbiB4bWxuczp4c2k9Imh0dH"; my-param*1="A6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNl"; my-param*2="IiB4bWxdfgg4c2Q9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE"; my-param*3="1MU2NoZW1hIiB4bWxuczpkcz0iaHR0cDovL3d3dy53My5vcmcv"; my-param*4="MjAwMC8wOS94bWxkc2lnIyIgeG1sbnM6eG1pbWU9Imh0dHA6Ly"; my-param*5="93d3cudzMub3JnLzIwMDUvMDUveG1sbWltZSIgeG1sbnM6bWI9"; my-param*6="InVybjpuYXR934dfgfdhZzo0Nzc4OmJpbmRpbmdpbmZvcm1hdG"; my-param*7="lvbjoxOjAiPjxtYjpNZXRhZGF0YUJpbmRpbmdDb250YWluZXI+"; my-param*8="PG1iOk1ldGFkYXRhQmluZGluZz48bWI6TWV0YWRhdGE+PHNsYW"; my-param*9="I6b3JpZ2luYXRvckNvbmZpZGVudGlhbGl0eUxhYmVsIHhtbG5z"; my-param*10="OnNsYWI9InVybjpuYXRvOnN0YW5hZzo0Nzc0OmNvbmZpZGVudG"; my-param*11="lhbGl0eW1ldGdfgfdgfdagfdaggTowIj48c2xhYjpDb25maWRl"; my-param*12="lhbGl0eW1ldGdfgfdgfdagfdaggTowIj48c2xhYjpDb25maWRl"; my-param*13="lhbGl0eW1ldGdfgfdgfdagfdaggTowIj48c2xhYjpDb25maWRl"; my-param*14="lhbGl0eW1ldGdfgfdgfdagfdaggTowIj48c2xhYjpDb25maWRl"; my-param*15="lh1sdffW1ldGFkYXRhbGFiZWw6MTowIj48c2xhYjpDb25maWRl";
this header is valid according to RFC 5322 and I try to add it like
export async function addHeader(data) { let result = false const item = Office.context.mailbox.item await item.internetHeaders.setAsync({ "my-header": data }, function (asyncResult) { console.log('got result') console.log(asyncResult.status) result = asyncResult.status === Office.AsyncResultStatus.Suceeded }) }
My current use case is to use it for labels like described in RFC 7444 but there are surely other use cases as well.
Implementing this check wouldn't be very complicated, we did it ourselves for our product.
as side information:
VSTO plugins can succesfully add this header to the email.
Please add support for RFC 5322 folding headers.
here is the link to the github issues -> https://github.com/OfficeDev/office-js/issues/3546