Reputation: 1093
I have an email that was sent to me with an attachment, however for some reason it came through as a base64 encoded string. Half way down the email it looks like this;
Content-Type: application/x-zip-compressed; name="me.zip";
Content-Disposition: attachment; filename="me.zip"
Content-Transfer-Encoding: base64
UEsDBBQAAQAIANeV9y5y6d5oG..... etc.
I have tried copying it in to an online base64 decoder (using utf-8) and then copying the resultant text in to a file and renaming as .zip, but this does not work. Can anyone help me get this attachment? There is no way of getting another copy.
Thanks for any help.
Upvotes: 0
Views: 3559
Reputation: 117344
Since you tagged this as "c#" I reckon you are OK writing a brief code snippet, in which case you can use Convert.FromBase64String, then write the resulting byte array to a file.
The linked Microsoft documentation shows an example of just what you want -- reading a file, decoding it from base 64, and then writing the result.
Upvotes: 1