0

This question is related to the following: Unexpected characters returned when reading email using ImapX

The solution here doesn't work.

The problem is that in some cases, the following string:

) IMAPX10 OK UID completed

is being added to the end of an attachment Base64 string. This causes the Base64 decoder throw an exception.

I tried fixing the

MessageContent.cs

file like the above solution, but with no luck...

Does anyone came accross with this problem?

Jokdex
  • 1

2 Answers2

1

ImapX is buggy and it's a serious bug. Fix it (it's open source after all) or use something else.

Fetch command processing involves returning x fetch items for each of y messages. One of those items is the base64 you want, and I assume y=1 in your case. The ) you see indicates the end of the item list for a particular message, and the OK... indicates the end of the command processing for the command tagged IMAPX10. There's a byte count just before the base64 that describes the length of that item, a byte count that ImapX really should not disregard.

arnt
  • 8,949
  • 5
  • 24
  • 32
0

For anyone else running into this issue, I fixed it with the following:

Convert.FromBase64String(attachment.GetTextData());

This will give you the proper byte array, without the unnecessary bytes at the end of the file.