From: Martin Gregorie on
On Thu, 10 Jun 2010 19:04:36 -0700, Roedy Green wrote:

> On Thu, 10 Jun 2010 02:04:40 -0700 (PDT), "eunever32(a)yahoo.co.uk"
> <eunever32(a)yahoo.co.uk> 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 |
From: Martin Gregorie on
On Thu, 10 Jun 2010 19:04:36 -0700, Roedy Green wrote:

> On Thu, 10 Jun 2010 02:04:40 -0700 (PDT), "eunever32(a)yahoo.co.uk"
> <eunever32(a)yahoo.co.uk> 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 |
From: Martin Gregorie on
On Thu, 10 Jun 2010 19:04:36 -0700, Roedy Green wrote:

> On Thu, 10 Jun 2010 02:04:40 -0700 (PDT), "eunever32(a)yahoo.co.uk"
> <eunever32(a)yahoo.co.uk> 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 |
From: Martin Gregorie on
On Thu, 10 Jun 2010 19:04:36 -0700, Roedy Green wrote:

> On Thu, 10 Jun 2010 02:04:40 -0700 (PDT), "eunever32(a)yahoo.co.uk"
> <eunever32(a)yahoo.co.uk> 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 |
From: eunever32 on
On Jun 11, 1:06 pm, Martin Gregorie <mar...(a)address-in-sig.invalid>
wrote:
> On Thu, 10 Jun 2010 19:04:36 -0700, Roedy Green wrote:
> > On Thu, 10 Jun 2010 02:04:40 -0700 (PDT), "euneve...(a)yahoo.co.uk"
> > <euneve...(a)yahoo.co.uk> 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.