When attempting to download attachments (and embedded resources), I receive an System.FormatException on the FileData property of the attachment:
```
System.FormatException
"The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters."
```
My code looks like this:
```
var messages = Client.Folders["INBOX"].Search("UNSEEN");
foreach(var message in messages)
{
...
foreach(var attachment in message.Attachments)
{
attachment.Download();
}
}
```
Before downloading, every attachment shows the file name and size. It simply fails when executing the download method. I'm using hMailServer, .NET 4.5 and IMapX version 2.0.0.18.
Comments: ** Comment from web user: nielsvos **
```
System.FormatException
"The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters."
```
My code looks like this:
```
var messages = Client.Folders["INBOX"].Search("UNSEEN");
foreach(var message in messages)
{
...
foreach(var attachment in message.Attachments)
{
attachment.Download();
}
}
```
Before downloading, every attachment shows the file name and size. It simply fails when executing the download method. I'm using hMailServer, .NET 4.5 and IMapX version 2.0.0.18.
Comments: ** Comment from web user: nielsvos **
Hi,
I found the bug that causes this. A string "(IMAPXXX OK UID completed." is added to every attachment, causing the download method to fail, because the base64 string is no longer valid.
Example of attachment string:
```
LHrt64/Gsa5a21WzGu7d5id4U3YIJkbgqnZufbHrXNVte9xqK5tD//2Q==)IMAPX29 OK UID completed
```
If you inspect the ContentStream in MessageContent.cs on line 314 during run-time, you will notice the above. When I added the following code, removing the additional text, the download worked just fine.
```
int index = ContentStream.IndexOf(")IMAPX");
if (index != -1)
{
ContentStream = ContentStream.Remove(index);
}
```