0
votes

I tried using an online base 64 decoder and managed to decode text and picture attachments successfully.

However, when it comes to MS word and Excel attachments, i was unable to decode it Could you please suggest me the correct decoding method.

Any help appreciated!

1
Post the MIME headers for the message that you are trying to process so we can look at them.Richard Schwartz
the sample encoded string is here page-monitor.com/Downloads/test.txt. i want to decode the above content and write it to a docx fileHaseena Parkar
It appears to be valid base64 data. What are you using to try to decode it?Richard Schwartz
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding(); System.Text.Decoder utf8Decode = encoder.GetDecoder(); byte[] todecode_byte = Convert.FromBase64String(data); int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); char[] decoded_char = new char[charCount]; utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0); result = new String(decoded_char);Haseena Parkar
If the word and excel files are binary, then I think you probably don't want to be going through the utf8Decode step.Richard Schwartz

1 Answers

0
votes

If a base64-decoding still results "garbage content" - there is a probability the data also has been compressed (with Huffman or LZ1 method). Check "compression" attribute value of its enclosing tag.

If the attribute indicates a compression - it is quite tricky to uncompress. A better idea would be to export the DXL again with setUncompressAttachments(true) mode of DXLExporter.