How to convert an email attachment to XML?

I am a bit lost in the different encoding types, it seems – I know why I prefer the Xojo framework usually …
Anyway, I’d be grateful for some advice: I set up a desktop project that uses a Pop3SecureSocket to scan through my emails, and if TopLinesRetrieved found some conditions to be true, I call a socket.RetrieveMessage on the mail id.
That works, and in the messageReceived event I receive the attachment.

I am only looking for XMLs, so I make a clumsy file name analysis (the workaround via text because instr sometimes gave me wrong trues; a better path would be to check the MiME type first – that’s all experimental!), well, and then I don’t know any further. I run into XML exceptions – not well formed (invalid token). I tried to read the attachment.ContentEncoding but despite what the LR says TextEncoding.Internetname seems to be read-only, so I don’t know how to use the ContentEncoding string.

[code]Sub MessageReceived(id as integer, email as emailMessage) Handles MessageReceived
for q as integer = 0 to email.Attachments.Ubound
dim att as EmailAttachment = email.Attachments(q)
dim attst as string = att.Name
dim attname as text =DefineEncoding (, Encodings.UTF8).totext
if attName.IndexOf(“XML”) > -1 then
dim data as string =
if data<> “” then
dim enc as TextEncoding
// enc.internetName= att.ContentEncoding // does not work
data = DecodeBase64 (
dim xml as new XmlDocument(data)
Catch XmlException

    end try
  end if
end if

End Sub[/code]

P.S.: @Christian Schmitz: Do you have classes that work faster? I found the toplinesRetrieved event of the built-in Pop3SecureSocket fires quite sparsely …

Feel free to try the CURL examples for email download.

Thanks, I’ll give it a try.
Found the solution in the old zymail project:

if att.ContentEncoding = kquotedprintable then data = DecodeQuotedPrintable ( elseif att.ContentEncoding = kbase64 then data = DecodeBase64( else MsgBox "Unknown encoding "+att.ContentEncoding break end if

The constants being “quoted-printable” and “base64”