Can I skip the MIME parsing to get the attachment?

I am new here so first of all greetings to you

I am writing an application to run on my Windows Mobile (Pocket PC). FYI, I am using VB.NET.

My idea is to use my email account with my ISP which gives me a lot of GB: s to use as a virtual online storage drive. In a few words, more or less similar to the GMAIL drive you may have read about. I've already written the code to connect using a telnet socket to my SMTP, POP3 and IMAP providers. I can log on and hence so good.

In my particular case, I'm not interested in the email messages themselves, but in fact the attachments that will be my files on this virtual memory stick. I found many free classes, mostly in C #, for loading emails with attachments and most importantly MIME parsing. Unfortunately, all of these classes, in one way or another, use the Net Framework classes / namespaces that are not included in the NET Compact Framework that Windows Mobile uses. Writing a MIME parser is too difficult for me and my knowledge.

So, at least in regards to my code for receiving via POP3 or IMAP, I thought that once I download all the bytes on my device, I would just parse the full email (checking where the boundaries are) and get the part (s) ) that have been Base64 encoded and then decode and rename them using the name and extension of the file I wrote in the email subject field at the time of sending. This way I could possibly avoid all things about MIME and all its meanings ...

As for sending via SMTP, I still need to look into it. Any ideas would be appreciated.

Sorry for this novel - do you think it is possible to skip getting the MIME parsers and just use normal string parsing?

Regards, Moster67

+1


source to share


3 answers


A MIME parser is just a string parser. They are very easy to write, especially if you know you just want / need a subset of MIME types. Take a look at the RFC and implement it yourself.



+1


source


You can try to find borders in post headers and then split the email into that line. Parsing the child elements will be IMHO necessary (coding and encoding comes to mind, and just dropping the headers won't work in most cases), but it's a little easier than dealing with the whole message at once.



A word of caution: this is a fragile approach - it will work on some messages, but breaks on others (e.g. nested multi-page messages, changing the line border (shouldn't, but can happen), etc.).

+1


source


writing an IS mailing parser is actually writing a simple MIME parser. You can write a quick and dirty MIME parser in a few hours. If you will use it to parse similar emails (for example, sent from the same place by the same client software), it should have everything you need.

For more information on MIME, see

Several days of work should be realistic. I participated in the development of a simple internal MIME parser (took a few days to hack and analyze 95% of the emails received) that were included in a commercial product (months of work, tons of unittest and hudreds really vierd test emails from the wilderness) and then has been modified so it can be used in the Compact Framework (changes due to memory constrained devices, changes because only a small part of the .NET framework is ported to .NET CF). And add a rewrite of quite a bit of CryptoAPI functionality to make signed and encrypted S / MIME emails work on .NET CF.

The MIME parser is part of the Rebex Secure Mail component for .NET / .NET CF and can be downloaded from http://www.rebex.net/secure-mail.net/

All versions of .NET and .NET CF are supported. Even the .NET CF1 dinosaur ;-). However, it is not free.

+1


source







All Articles