Prev: hibernate question ?
Next: 10 MAXIMO positions in Austin, TX.,- duration 6+ months - Interviews over Phone
From: eunever32 on 11 Jun 2010 11:53 Hopefully this clarifies my earlier post. I have little knowledge of Javamail but I need to read an attachment from an email I have the result of a decrypted email stored in a file as below I can do: MimeMessage msg = new MimeMessage(session, new FileInputStream("file.txt")); The resulting message has three headers which seems correct msg.getContent() is not an instanceof Multipart Is there some way to obtain the attachment?? This is a multipart message in MIME format. --=_mixed 00561CF28025770E_= Content-Type: multipart/alternative; boundary="=_alternative 00561CF28025770E_=" --=_alternative 00561CF28025770E_= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: base64 --=_alternative 00561CF28025770E_= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: base64 DQo= --=_alternative 00561CF28025770E_=-- --=_mixed 00561CF28025770E_= Content-Type: text/plain; name="TEST.txt" Content-Disposition: attachment; filename="TEST.txt" Content-Transfer-Encoding: quoted-printable Some text Some more text And some more --=_mixed 00561CF28025770E_=--
From: Lothar Kimmeringer on 11 Jun 2010 16:18 eunever32(a)yahoo.co.uk wrote: > I have little knowledge of Javamail but I need to read an attachment > from an email > > I have the result of a decrypted email stored in a file as below > > I can do: > > MimeMessage msg = new MimeMessage(session, new > FileInputStream("file.txt")); > The resulting message has three headers which seems correct Three headers for a mail is too less. From, To, Subject and Date are only the standard ones and we're not talking about the headers you need to get a MIME-message > msg.getContent() is not an instanceof Multipart What is the type of getContent, what is the complete decrypted mail (i.e. with the headers). Without that nobody will be able to tell you more than: Something doesn't seem to be right. Regards, Lothar -- Lothar Kimmeringer E-Mail: spamfang(a)kimmeringer.de PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81) Always remember: The answer is forty-two, there can only be wrong questions!
From: eunever32 on 12 Jun 2010 10:46 On Jun 11, 9:18 pm, Lothar Kimmeringer <news200...(a)kimmeringer.de> wrote: > euneve...(a)yahoo.co.uk wrote: > > I have little knowledge of Javamail but I need to read an attachment > > from an email > > > I have the result of a decrypted email stored in a file as below > > > I can do: > > > MimeMessage msg = new MimeMessage(session, new > > FileInputStream("file.txt")); > > The resulting message has three headers which seems correct > > Three headers for a mail is too less. From, To, Subject and > Date are only the standard ones and we're not talking about > the headers you need to get a MIME-message > > > msg.getContent() is not an instanceof Multipart > > What is the type of getContent, what is the complete decrypted > mail (i.e. with the headers). Without that nobody will be able > to tell you more than: Something doesn't seem to be right. > > Regards, Lothar > -- > Lothar Kimmeringer E-Mail: spamf...(a)kimmeringer.de > PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81) > > Always remember: The answer is forty-two, there can only be wrong > questions! Lothar Thanks for the reply. The type of the content is ByteArrayInputStream The full text of the email is as follows (I'm not storing the from, to etc.) Thanks STARTS HERE This is a multipart message in MIME format. --=_mixed 00561CF28025770E_= Content-Type: multipart/alternative; boundary="=_alternative 00561CF28025770E_=" --=_alternative 00561CF28025770E_= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: base64 --=_alternative 00561CF28025770E_= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: base64 DQo= --=_alternative 00561CF28025770E_=-- --=_mixed 00561CF28025770E_= Content-Type: text/plain; name="TEST.txt" Content-Disposition: attachment; filename="TEST.txt" Content-Transfer-Encoding: quoted-printable Some text Some more text And some more --=_mixed 00561CF28025770E_=-- ENDS HERE
From: Steven Simpson on 12 Jun 2010 11:31 On 12/06/10 15:46, eunever32(a)yahoo.co.uk wrote: > The full text of the email is as follows (I'm not storing the from, to > etc.) > Thanks > STARTS HERE > This is a multipart message in MIME format. > --=_mixed 00561CF28025770E_= > Content-Type: multipart/alternative; boundary="=_alternative > 00561CF28025770E_=" > I'm guessing, but if this is all you're supplying to MimeMessage, how can it determine that it is multipart? It surely needs: Content-Type: multipart/something; boundary="=_mixed 00561CF28025770E_=" .... i.e. it's missing the headers. (The Content-Type you do show appears to be one of the parts, which itself happens to be multipart.)
From: Lew on 12 Jun 2010 11:43 eunever32(a)yahoo.co.uk wrote: >>> msg.getContent() is not an instanceof Multipart Lothar Kimmeringer wrote: >> What is the type of getContent, what is the complete decrypted >> mail (i.e. with the headers). Without that nobody will be able >> to tell you more than: Something doesn't seem to be right. eunever32(a)yahoo.co.uk wrote: >> Regards, Lothar >> -- >> Lothar Kimmeringer E-Mail: spamf...(a)kimmeringer.de >> PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81) >> >> Always remember: The answer is forty-two, there can only be wrong >> questions! Don't quote sigs. > The type of the content is ByteArrayInputStream You did an illegal thing in Java. Java is strongly typed. Types are a set of compiler-enforced constraints. You declared something like (and you should share an SSCCE): InputStream content = new ByteArrayInputStream( contentBytes ); For the variable type I purposely substituted the general 'InputStream' for the specific 'ByteArrayInputStream' you undoubtedly used. You have a 'msg.getContent()' that returns that 'content'. I'll give it credit for a declaration 'public InputStream getContent()'. But there's absolutely no way whatsoever that Java will give any kind of 'InputStream' credit for being a subtype or supertype of 'Multipart'. That's just your fundamental type-strong compiler constraints following the rules of the language, there. There must be some action, not a declarative type cast, that you really want to perform with that 'getContent()'. What is it? Oh, and you should share an SSCCE. http://sscce.org/ -- Lew
|
Next
|
Last
Pages: 1 2 Prev: hibernate question ? Next: 10 MAXIMO positions in Austin, TX.,- duration 6+ months - Interviews over Phone |