Re: encrypted javamail MimeMultipart



On Jun 11, 2:40 pm, "euneve...@xxxxxxxxxxx" <euneve...@xxxxxxxxxxx>
wrote:
On Jun 11, 1:06 pm, Martin Gregorie <mar...@xxxxxxxxxxxxxxxxxxxxxx>
wrote:





On Thu, 10 Jun 2010 19:04:36 -0700, Roedy Green wrote:
On Thu, 10 Jun 2010 02:04:40 -0700 (PDT), "euneve...@xxxxxxxxxxx"
<euneve...@xxxxxxxxxxx> wrote, quoted or indirectly quoted someone who
said :

How can I cast this to a MimeMultipart ?

I have not done this myself, but it seems to me you need four steps:

1. get the armoured encrypted message characters, with headers stripped
off.

2. strip off the armouring so you have an array of bytes.

3. run this through the decryption algorithm.

4. convert the decrypted bytes back into characters via some encoding..

(4) should become:
    - create a ByteArrayInputStream from the decrypted byte array
    - pass that to a MimeMessage constructor.

    At this point you can use the standard MimeMessage and MultiPart
    methods to parse the message and extract its content.

--
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |- Hide quoted text -

- Show quoted text -

Thanks Martin but maybe you can help me:

As I said I'm new to this Javamail api and am looking for a succinct
way to obtain the attachment

I can do

MimeMessage msg = new MimeMessage(session, new
FileInputStream("file.txt"));

The resulting msg has three headers which looks right

But when I do
if (msg.getContent() instanceof Multipart) {
     saveAttachment

}

It transpires it's NOT an object of type Multipart ... so what can I
do ???

I think at this stage it's basic javamail I require but am struggling.

Thanks.- Hide quoted text -

- Show quoted text -

In other words when I try this
Multipart multipart = (Multipart) content;
Exception in thread "main" java.lang.ClassCastException:
com.sun.mail.util.SharedByteArrayInputStream
.



Relevant Pages

  • Re: encrypted javamail MimeMultipart
    ...     pass that to a MimeMessage constructor. ... if instanceof Multipart) { ... how to parse a multipart MIME message. ...
    (comp.lang.java.programmer)
  • Re: encrypted javamail MimeMultipart
    ...     pass that to a MimeMessage constructor. ... if instanceof Multipart) { ... how to parse a multipart MIME message. ...
    (comp.lang.java.programmer)
  • Re: Mail Anhang lesen: javax.mail.MessagingException: Missing start boundary
    ...    public Object anhangLesen{ ... Unter Umständen ist die Mail ja kein Multipart sondern einfach plain. ... Object obj = msg.getContent; ... Wenn Frauen nicht wissen was sie machen sollen, ...
    (de.comp.lang.java)
  • Re: encrypted javamail MimeMultipart
    ...     - create a ByteArrayInputStream from the decrypted byte ... if instanceof Multipart) { ... And don't forget that a MIME message is a recursive ... martin@ | Martin Gregorie ...
    (comp.lang.java.programmer)
  • Re: encrypted javamail MimeMultipart
    ...     - create a ByteArrayInputStream from the decrypted byte ... if instanceof Multipart) { ... And don't forget that a MIME message is a recursive ...
    (comp.lang.java.programmer)