javamail - Failing to parse this multi-part mime message body in Java -


i'm not writing mail application, don't have access headers , such. have block @ end of question. i've tried using javamail api parse this, using like

session s = session.getdefaultinstance(new properties()); inputstream = new bytearrayinputstream(<< string parse >>); mimemessage message = new mimemessage(s, is); multipart multipart = (multipart) message.getcontent(); 

but, tells me message.getcontent string, not multipart or mimemultipart. plus, don't need overhead of whole javamail api, need parse text it's parts. here's example:

 multi-part message in mime format.\n\n------=_nextpart_000_005d_01cc73d5.3ba43fb0\ncontent-type: text/plain;\n\tcharset="iso-8859-1"\ncontent-transfer-encoding: quoted-printable\n\nstuff:\n\n            please read stuff @ beginning of each week.  =\nfeel free discuss throughout week.\n\n\n--=20\n\nmrs. suzy m. smith\n555-555-5555\nsuzy@suzy.com\n------=_nextpart_000_005d_01cc73d5.3ba43fb0\ncontent-type: text/html;\n\tcharset="iso-8859-1"\ncontent-transfer-encoding: quoted-printable\n\n\n\n\n\n\n\n\n\nstuff:

\n           =20\nplease read stuff @ beginning of each =\nweek.  feel=20\nfree discuss throughout week.

\n
--

mrs. suzy m. smith
555-555-5555
suzy@suzy.com\n\n------=_nextpart_000_005d_01cc73d5.3ba43fb0--\n\n

there few things wrong text posted.

it not valid multi-part mime. check out wikipedia reference which, while non-normative, still correct.

the mime boundary not defined. wikipedia example: content-type: multipart/mixed; boundary="frontier" shows boundary "frontier". in example, "----=_nextpart_000_005d_01cc73d5.3ba43fb0" boundary, can determined scanning text (i.e. mime malformed). need instruct goofball passing mime content need know mime boundary value, not defined in message header. if entire body of message have enough because body of message starts mime-version: 1.0 followed content-type: multipart/mixed; boundary="frontier" frontier replaced value of boundary encoded mime.

if person sending body goofball (changed monkey because monkey judgemental - bad dwb), , not (more not know how to) send full body, can derive boundary scanning text line starts , ends "--" (i.e. --boundary--). note mentioned "line". terminal boundary "--boundary--\n".

finally, stuff posted has 2 parts. first part appears define substitutions take place in second part. if true, content-type: of first part should other "text/plain". perhaps "companyname/substitution-definition" or that. allow multiple (as in future enhancements) substitution formats.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -