|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
POP 3 attachmentUsing winsock, how can I read POP 3 email attachment (the attachment is an
..EML file) ? Thank you On 06/09/2010 20:55, fniles wrote:
> Using winsock, how can I read POP 3 email attachment (the attachment is an Have a look at RFC1939 for the POP3 protocol (It's as easy as login, get > .EML file) ? message, disconnect), and then RFC822, the MIME/multipart MIME specs and base64 decoding (if required). If the attachment is another email, then that is nothing special, it's just the same structure again. -- Dee Earley (dee.ear***@icode.co.uk) i-Catcher Development Team iCode Systems (Replies direct to my email address will be ignored. Please reply to the group.) Thank you
What is RFC1939 and RFC822 ? Where can I find it ? Show quoteHide quote "Dee Earley" <dee.ear***@icode.co.uk> wrote in message news:%23QILCEmTLHA.5944@TK2MSFTNGP06.phx.gbl... > On 06/09/2010 20:55, fniles wrote: >> Using winsock, how can I read POP 3 email attachment (the attachment is >> an >> .EML file) ? > > Have a look at RFC1939 for the POP3 protocol (It's as easy as login, get > message, disconnect), and then RFC822, the MIME/multipart MIME specs and > base64 decoding (if required). > If the attachment is another email, then that is nothing special, it's > just the same structure again. > > -- > Dee Earley (dee.ear***@icode.co.uk) > i-Catcher Development Team > > iCode Systems > > (Replies direct to my email address will be ignored. > Please reply to the group.) "fniles" <fni***@pfmail.com> wrote in message
http://www.lmgtfy.com/?q=RFC1939
news:e8n3JOtTLHA.2068@TK2MSFTNGP05.phx.gbl... > Thank you > > What is RFC1939 and RFC822 ? > Where can I find it ? <g> On Tue, 7 Sep 2010 16:27:53 -0500, "fniles" <fni***@pfmail.com> wrote: The poorly named bible/s for the internet ...>Thank you > >What is RFC1939 and RFC822 ? >Where can I find it ? > "Request For Comments" "Post Office Protocol - Version 3" http://tools.ietf.org/html/rfc1939 "Internet Text Messages" http://tools.ietf.org/html/rfc822 -ralph | Thank you The RFCs are the official documentation, but| | What is RFC1939 and RFC822 ? | Where can I find it ? that's a wild goose chase. It's like telling you to read the official 2010 tax code to find out whether you can deduct your office in the home. The info. is in there...but you'll never find it. I already told you how to find the attachment and retrieve it. If you don't understand just try looking at the raw text of a few emails. The MIME format is text-based and systematic. You can parse it just like an email program can parse it. I just tried this. It's a little bit tricky, at least in
OE, because the attached email was not fully encoded. It was just sandwiched. Normally when you attach a file it gets inserted as a single Base64 string. (Note that you may have to remove carriage returns, tabs, or other formatting junk before decoding Base64.) Here's a sample of the format for an email with a JPG attachment. Note that the "boundary" value defines a random string that separates sections of the email. The email is parsed using boundary markers and empty lines to identify content. Boundaries must begin with "--". The closing boundary begins with "--" and also ends with "--". _________ Begin sample ______________ from to date subject Message-ID MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="BOUNDARY_STRING_1" X-Mailer: [email program name here] # --BOUNDARY_STRING_1 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit # (email text here) # --BOUNDARY_STRING_1 Content-Type: image/jpeg; name="pic1.jpg" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="pic1.jpg" # (base 64 here) # --BOUNDARY_STRING_1-- ________________ end sample ________ Notice that the attachment is identified with the line: Content-Disposition: attachment The beginning of the attachment info. is marked by a boundary string. The Base64 string representing the actual file content has an empty line before and after. So it's fairly easy to check for attachments and it's easy to extract the attachment(s). When I created an email with an attachment, then attached that to another email, I ended up with the entire first email copied in the second email. It began with this: Content-Type: message/rfc822; name="mmm.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="mmm.eml" But then instead of a blank line followed by Base64, there was a blank line followed by the raw text of the first email: From: To: Subject: ..etc. The attachment in the attached email is still there. Then the end is like this: --Boundary_string_from_attached_email-- --Boundary_string_from_main_email-- So you have to parse an email within an email. But as you can see from the snippets I've posted, it still follows standards. You'll look for Content-Disposition: attachment with Content-Type: message/rfc822 (It may be possible for an email to have other content type. i'm not sure.) The attached email will start after the next blank line. From there you find boundary= then find the end of the attached email by looking for that with "--" appended. Note, however, that the boundary is only necessary where Content-Type is multipart/* If Content-Type is text/plain in the attached email, the end of the attached email may be delineated only by a boundary marker in the main email. Basically, attached plain text is inserted as plain text. Attached binary data is base64-encoded. In the case of an attached email with attachments, the attachment can be both because the actual file content of the attached .EML is both. (It's all plain text, technically, but any base64-encoded content represents binary data.) So in order to know whether you need to do any base64 decoding you need to check the Content-Type of the attachment. And you might have to do that recursively if you have an attached EML file. (I know this all sounds confusing, but it's actually a simple and fairly sensible system once you get the gist of it.) Thank you, all.
Is it possible to save the attachment as a file, so that I can resend the attachment as a file in another email ? Show quoteHide quote "Mayayana" <mayayana@invalid.nospam> wrote in message news:i66vu7$bup$1@news.eternal-september.org... > I just tried this. It's a little bit tricky, at least in > OE, because the attached email was not fully > encoded. It was just sandwiched. Normally when you > attach a file it gets inserted as a single Base64 string. > (Note that you may have to remove carriage returns, > tabs, or other formatting junk before decoding Base64.) > > Here's a sample of the format for an email with > a JPG attachment. Note that the "boundary" value > defines a random string that separates sections of the > email. The email is parsed using boundary markers > and empty lines to identify content. Boundaries must > begin with "--". The closing boundary begins with > "--" and also ends with "--". > > _________ Begin sample ______________ > > from > to > date > subject > Message-ID > MIME-Version: 1.0 > Content-Type: multipart/mixed; > boundary="BOUNDARY_STRING_1" > X-Mailer: [email program name here] > # > --BOUNDARY_STRING_1 > Content-Type: text/plain; > charset="iso-8859-1" > Content-Transfer-Encoding: 7bit > # > (email text here) > # > --BOUNDARY_STRING_1 > Content-Type: image/jpeg; > name="pic1.jpg" > Content-Transfer-Encoding: base64 > Content-Disposition: attachment; > filename="pic1.jpg" > # > (base 64 here) > # > --BOUNDARY_STRING_1-- > > ________________ end sample ________ > > Notice that the attachment is identified > with the line: > > Content-Disposition: attachment > > The beginning of the attachment info. is marked > by a boundary string. The Base64 string representing > the actual file content has an empty line before and > after. So it's fairly easy to check for attachments > and it's easy to extract the attachment(s). > > When I created an email with an attachment, then > attached that to another email, I ended up with the > entire first email copied in the second email. It began > with this: > > Content-Type: message/rfc822; > name="mmm.eml" > Content-Transfer-Encoding: 7bit > Content-Disposition: attachment; > filename="mmm.eml" > > But then instead of a blank line followed by Base64, there > was a blank line followed by the raw text of the first email: > > From: > To: > Subject: > ..etc. > > The attachment in the attached email is still there. Then > the end is like this: > > --Boundary_string_from_attached_email-- > > --Boundary_string_from_main_email-- > > > So you have to parse an email within an email. But as > you can see from the snippets I've posted, it still follows > standards. You'll look for > > Content-Disposition: attachment > with > Content-Type: message/rfc822 > > (It may be possible for an email to have other content > type. i'm not sure.) > > The attached email will start after the next blank line. > From there you find > > boundary= > > then find the end of the attached email by > looking for that with "--" appended. Note, > however, that the boundary is only necessary > where Content-Type is multipart/* > If Content-Type is text/plain in the attached > email, the end of the attached email may be delineated > only by a boundary marker in the main email. > > Basically, attached plain text is inserted as > plain text. Attached binary data is base64-encoded. > In the case of an attached email with attachments, > the attachment can be both because the actual file > content of the attached .EML is both. (It's all plain > text, technically, but any base64-encoded content > represents binary data.) So in order to > know whether you need to do any base64 decoding you > need to check the Content-Type of the attachment. > And you might have to do that recursively if you have > an attached EML file. > > (I know this all sounds confusing, but it's actually > a simple and fairly sensible system once you get > the gist of it.) > > | Why not? It's coming through as the complete text| Is it possible to save the attachment as a file, so that I can resend the | attachment as a file in another email ? | of an email. The whole thing is just text. You just have to identify the beginning and end of the attached email, get that text, and save it.
Any "quirsk" with the timer control
DLL fight create desktop shortcut when app installed w/P&D installer for XP,Vista,W7 What Is the User Path for Deployment Similar to $(AppPath)? Looking for VC6 newsgroup Error 481 Invalid picture Global class and WithEvents Closing Grouped instances in the taskbar Componenet not installed correctly by PDW Error 5: ERROR_ACCESS_DENIED when accessing registry in Windows 7 |
|||||||||||||||||||||||