Quantcast
Channel: ImapX 2
Viewing all articles
Browse latest Browse all 1952

Commented Unassigned: Saving Excel xlsx attachments are corrupt [2709]

$
0
0
When using either the attachments.Save() method or the attachments.FileData method to save the file to disc, the following message is encoutered:

____We found a problem with some content in ???.xslx. Do you want us to try to recover as much as we can?____

This only occurs with xlsx attachments and the attachments are not corrupted when opened or saved directly from the mailbox.

The host I'm using in Office 365 and the script is using powershell. I've attached part of the code.

Regards, Matt
Comments: ** Comment from web user: barryjacobs **

I had the same problem too, there's a bug in the Base64.cs FromBase64 function, that's causing the corruption.

I didn't fix this directly but found an alternative decode, that solves the problem:

byte[] output;
using (var ms = new MemoryStream())
using (var cs = new CryptoStream(ms, new FromBase64Transform(), CryptoStreamMode.Write))
using (var tr = new StreamWriter(cs))
{
tr.Write(s);
tr.Flush();
output = ms.ToArray();
}
return output;

This is referenced in:

http://stackoverflow.com/questions/28105486/decode-large-base64-strings


Viewing all articles
Browse latest Browse all 1952

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>