Closed MrFJ closed 3 months ago
Sounds like the data you are trying to parse isn't valid MIME.
Do you have the raw data that you can share?
I'm finding it tough to extract the full data from visual studio, but this is the start of it:
"l\u0005\0\0\u0001\0\0\0\v\0\0\0m\0a\0i\0l\0l\0i\0s\0t\0r\0o\0w\0\0\0�\u0002\0\0{\0\"\0i\0t\0e\0m\0T\0y\0p\0e\0\"\0:\0\"\0m\0a\0i\0l\0l\0i\0s\0t\0r\0o\0w\0\"\0,\0\"\0t\0a\0b\0l\0e\0V\0i\0e\0w\0I\0d\0\"\0:\0\"\0f\0o\0l\0d\0e\0r\0I\0d\0:\0A\0A\0M\0k\0A\0D\0J\0l\0M\0j\0I\03\0O\0D\0J\0m\0L\0T\0F\0m\0Z\0W\0M\0t\0N\0D\0Y\04\0M\0y\00\05\0M\0D\0B\0h\0L\0T\0d\0k\0M\0z\0E\0z\0N\0j\0d\0k\0Z\0T\0V\0h\0N\0w\0A\0u\0A\0A\0A\0A\0A\0A\0C\0g\0K\0x\0b\0r\0v\0k\0q\06\0T\06\0i\0e\0J\0G\0s\06\0k\0h\0C\0o\0A\0Q\0A\0P\0D\0Z\06\03\0D\0q\0p\0f\0S\07\0x\0w\0d\0n\0K\0e\07\0N\0W\0W\0A\0A\0A\0A\0A\0A\0E\0P\0A\0A\0A\0=\0;\0l\0V\0T\0:\01\0;\0v\0F\0:\0A\0l\0l\0;\0f\0V\0F\0:\0-\01\0;\0s\0C\0:\01\0;\0s\0D\0:\0D\0e\0s\0c\0e\0n\0d\0i\0n\0g\0;\0s\0T\0:\0m\0a\0i\0l\0\"\0,\0\"\0t\0a\0b\0l\0e\0L\0i\0s\0t\0V\0i\0e\0w\0T\0y\0p\0e\0\"\0:\01\0,\0\"\0r\0o\0w\0K\0e\0y\0s\0\"\0:\0[\0\"\0A\0Q\0A\0A\0A\0A\0A\0A\0A\0Q\08\0B\0A\0A\0A\0E\0k\0H\0M\0+\03\0w\0A\0A\0A\0A\0A\0=\0\"\0]\0,\0\"\0s\0u\0b\0j\0e\0c\0t\0s\0\"\0:\0[\0\"\0t\0e\0s\0t\0\"\0]\0,\0\"\0l\0a\0t\0e\0s\0t\0I\0t\0e\0m\0I\0d\0s\0\"\0:\0[\0\"\0A\0A\0M\0k\0A\0D\0J\0l\0M\0j\0I\03\0O\0D\0J\0m\0L\0T\0F\0m\0Z\0W\0M\0t\0N\0D\0Y\04\0M\0y\00\05\0M\0D\0B\0h\0L\0T\0d\0k\0M\0z\0E\0z\0N\0j\0d\0k\0Z\0T\0V\0h\0N\0w\0B\0G\0A\0A\0A\0A\0A\0A\0C\0g\0K\0x\0b\0r\0v\0k\0q\06\0T\06\0i\0e\0J\0G\0s\06\0k\0h\0C\0o\0B\0w\0A\0P\0D\0Z\06\03\0D\0q\0p\0f\0S\07\0x\0w\0d\0n\0K\0e\07\0N\0W\0W\0A\0A\0A\0A\0A\0A\0E\0P\0A\0A\0A\0P\0D\0Z\06\03\0D\0q\0p\0f\0S\07\0x\0w\0d\0n\0K\0e\07\0N\0W\0W\0A\0A\0S\0Q\0c\0z\07\0f\0A\0A\0A\0=\0\"\0]\0,\0\"\0m\0a\0i\0l\0b\0o\0x\0I\0n\0f\0o\0s\0\"\0:\0..."
The dragevent has data in 5 formats: "DragContext", "DragImageBits", "chromium/x-renerer-taint", "FileDrop", and "Chromium Web Custom MIME Data Format". Given that trying to get the "FileDrop" data throws an "Invalid FORMATETC structure (0x80040064 (DV_E_FORMATETC))" exception, I figured "Chromium Web Custom MIME Data Format" would be the right choice since it contains the correct data once you manually parse it. Sorry if I'm way off; I'm quite new to reading mails using code...
That looks like binary data to me.
I just need you to write the contents of this stream to a file or something:
Stream stream = dragEventArgs.Data.GetData("Chromium Web Custom MIME Data Format") as Stream;
Is that what produced that binary data? If so, that's not valid MIME and that is why MimeKit can't parse it.
The data I posted (Which with some Copilot help, contains the body and header of my email) was what I got from the visual studio preview of this:
string text = dragEventArgs.Data.GetData("Chromium Web Custom MIME Data Format") as string;
If I instead run this:
Stream stream = dragEventArgs.Data.GetData("Chromium Web Custom MIME Data Format") as Stream; StreamReader reader = new StreamReader(stream); Clipboard.SetText(reader.ReadToEnd());
And paste it into a file; I get this: l
And this code:
Stream stream = dragEventArgs.Data.GetData("Chromium Web Custom MIME Data Format") as Stream; StreamReader reader = new (stream); File.WriteAllText(@"C:\Users\ffpj\OneDrive - Kamstrup A S\Desktop\file.txt", reader.ReadToEnd());
Gives me this result:
l m a i l l i s t r o w � { " i t e m T y p e " : " m a i l l i s t r o w " , " r o w K e y s " : [ " A Q A A A A A A A Q 8 B A A A E k H M + 3 w A A A A A = " ] , " t a b l e V i e w I d " : " f o l d e r I d : IDOBFUSCATED; l V T : 1 ; v F : A l l ; f V F : - 1 ; s C : 1 ; s D : D e s c e n d i n g ; s T : m a i l " , " t a b l e L i s t V i e w T y p e " : 1 , " s u b j e c t s " : [ " t e s t " ] , " h a v e I R M " : [ f a l s e ] , " s i z e s " : [ 2 1 9 8 ] , " m a i l b o x I n f o s " : [ { " t y p e " : " U s e r M a i l b o x " , " s o u r c e I d " : " IDOBFUSCATED " , " u s e r I d e n t i t y " : " EMAILOBFUSCATED" , " m a i l b o x S m t p A d d r e s s " : " EMAILOBFUSCATED " } ] , " l a t e s t I t e m I d s " : [ " A A M k A D J l M j I 3 O D J m L T F m Z W M t N D Y 4 M y 0 5 M D B h L T d k M z E z N j d k Z T V h N w B G A A A A A A C g K x b r v k q 6 T 6 i e J G s 6 k h C o B w A P D Z 6 3 D q p f S 7 x w d n K e 7 N W W A A A A A A E P A A A P D Z 6 3 D q p f S 7 x w d n K e 7 N W W A A S Q c z 7 f A A A = " ] }
That's all the methods I can think of :)
I don't know what to suggest, but this obviously isn't a valid email for MimeKit to parse so there's not really a bug in MimeKit in this scenario.
If you can figure out how to get the MIME formatted message (which will be ascii text and not binary data), MimeKit will parse it correctly.
Describe the bug When I attempt to read the mail, I simply get a "Failed to read header" exception, with no inner exceptions.
Platform (please complete the following information):
To Reproduce I have a WPF application that accept dragdrop input. I'm attempting to read an outlook email from DragEventArgs. Once my app is set up to accept drop events, I drag a mail directly from the outlook app and read the Data as "Chromium Web Custom MIME Data Format".
Expected behavior I expect to get a MimeMessage i can further parse :)
Code Snippets
Additional context I'm using the "New" version of Outlook
Thoughts?