You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a use case where I want to use the Thread-Index header to link messages together (Yes I know there is also the References field but that one is not always filled in my case). I tried decoded this header AQHbJet7Z+efu/5M5UWYnpinBaQePrKfAKzegAAO5bCAAAHygIAAD3LwgAG3uyCAAAECjYAXUgfggASoxyCAAAqegIADX0fwgAFtahCAAAThwIAAAMtwgAAAupCAAAEUEIAAImAggAAHlkCAAC0xcA== with some example code that I found on the internet.
try{Raw=threadIndex;varbytes=Convert.FromBase64String(threadIndex);// Thread index length should be 22 plus extra 5 bytes per replyif(bytes.Length<22||(bytes.Length-22)%5!=0)return;Id=newGuid(bytes.Skip(6).Take(16).ToArray());varchildBlockCount=(bytes.Length-22)/5;if(childBlockCount==0)Date=DateTime.FromFileTimeUtc(bytes.Skip(1).Take(6).Select(b =>(long)b).Aggregate((l1,l2)=>(l1<<8)+l2)<<16).ToLocalTime();else{Date=DateTime.FromFileTimeUtc(bytes.Take(6).Select(b =>(long)b).Aggregate((l1,l2)=>(l1<<8)+l2)<<16).ToLocalTime();Dates=[Date];for(vari=0;i<childBlockCount;i++){varchildTicks=bytes.Skip(22+i*5).Take(4).Select(b =>(long)b).Aggregate((l1,l2)=>(l1<<8)+l2)<<18;childTicks&=~((long)1<<50);Date=Date.AddTicks(childTicks);if(i<childBlockCount-1)Dates.Add(Date);}}}catch{// Ignore}
With some headers this works but most of the times I just get dated in the year 1830 or in 1601 so something is different.
internalThreadIndex(string threadIndex){try{Raw=threadIndex;// Decode base64 string to bytesvarbytes=Convert.FromBase64String(threadIndex);// Validate minimum length (22 bytes for the header block)if(bytes.Length<22||(bytes.Length-22)%5!=0)return;// Parse the header blockif(bytes[0]!=1)// Reserved byte must be 1return;// Extract and compute the date from the FILETIME format in the headervarheaderTicks=bytes.Skip(1).Take(5).Select(b =>(long)b).Aggregate((l1,l2)=>(l1<<8)+l2)<<16;Date=DateTime.FromFileTimeUtc(headerTicks).ToLocalTime();// Extract GUID from the header blockId=newGuid(bytes.Skip(6).Take(16).ToArray());// Prepare the list of datesDates=newList<DateTime>{Date};// Parse child blocks (if present)varchildBlockCount=(bytes.Length-22)/5;for(vari=0;i<childBlockCount;i++){// Extract each child block (5 bytes)varchildBytes=bytes.Skip(22+i*5).Take(5).ToArray();// Extract the first bit (time encoding strategy)varstrategyBit=(childBytes[0]&0b10000000)!=0;// Extract the 31 bits for time differencevartimeDiff=((childBytes[0]&0b01111111)<<24)|(childBytes[1]<<16)|(childBytes[2]<<8)|childBytes[3];if(strategyBit)timeDiff<<=23;// High-precision, shift low 23 bitselsetimeDiff<<=18;// Low-precision, shift low 18 bits// Mask out the 50th bit to handle the encoding properlytimeDiff&=~((long)1<<50);// Compute the child date using the time differencevarchildDate=Date.AddTicks(timeDiff);Dates.Add(childDate);}}catch{// Ignore exceptions for invalid input}}
So I was wondering if you ever tried to do something like this with MimeKit?
The text was updated successfully, but these errors were encountered:
Note: I found your ThreadIndex implementation in mimekit but that also gives random junk dates when trying to decode the threadindex string in the post above.
For the moment I just gave up, I think the documentation on the Microsoft site is missing something and without knowing what it seems impossible to crack this egg.
Well give it a try, it drove me nuts this week because every time I thought I had everything working another thread-index failed with weird dates. For some reason I sometimes have to get the first 6 bytes from the header for a correct date time even when the specifications say that the first byte is reserved and always 1. In another situation I had to skip the first byte (specification) and then take the next 6 instead of 5....
I also had problems with the child blocks. When the header date was correct and there are for example 16 child block most of the blocks give correct dates but than a few of them give a date in the future ... like 2025 instead of 2024 ... so weird.
So that is why I think something is missing in the documentation on the Microsoft site. I also searched Google and asked ChatGPT but even that came up with not always working code. Al so other people seem to have the same problems that I ran into.
Also tried to find some C++ of working code in another language (so that I could port it) .... but al so no luck
I have a use case where I want to use the Thread-Index header to link messages together (Yes I know there is also the References field but that one is not always filled in my case). I tried decoded this header
AQHbJet7Z+efu/5M5UWYnpinBaQePrKfAKzegAAO5bCAAAHygIAAD3LwgAG3uyCAAAECjYAXUgfggASoxyCAAAqegIADX0fwgAFtahCAAAThwIAAAMtwgAAAupCAAAEUEIAAImAggAAHlkCAAC0xcA==
with some example code that I found on the internet.With some headers this works but most of the times I just get dated in the year 1830 or in 1601 so something is different.
I also tried following this documentation --> https://learn.microsoft.com/en-us/office/client-developer/outlook/mapi/tracking-conversations?redirectedfrom=MSDN ... but still no luck.
So I was wondering if you ever tried to do something like this with MimeKit?
The text was updated successfully, but these errors were encountered: