6 Replies Latest reply on Sep 6, 2006 10:51 AM by jhudson

    sample code for getting message body & attachments

    jhudson

      Hello,

      Could you point me to some sample code for getting the email body and attachments from a org.jboss.mail.message.Mail object? Or, if you could tell me (if this is possible) how I could get a javax.mail.internet.MimeMessage object? Thanks very much in advance.

      Joe Hudson

        • 1. Re: sample code for getting message body & attachments
          sappenin

          Have a look at the org.jboss.mail.userapi code, in particular the MailSender class. This is what the webmail uses to create/send email.

          Also, you might find something worthwhile in the org.jboss.mail.pop3.handlers package, in particular the CmdRETR class, which is (I believe) what the POP3 code uses to stream a message to a POP3 client.

          david

          • 2. Re: sample code for getting message body & attachments
            jhudson

            Thank you very much for the reply, David.

            Joe

            • 3. Re: sample code for getting message body & attachments
              jhudson

              I've looked at everything I can find (MailSenderImpl class and CmdRETR and org.jboss.mail.userapi) and I know I'm missing something obvious but I can't find any examples of getting message body content or attachments from a org.jboss.mail.message.Mail object. Does anybody have any other examples I might be able to look at? Thank you very much.

              Joe

              • 4. Re: sample code for getting message body & attachments
                osterday

                The writeMessage method in CmdRETR is useful as a start.

                Last I checked, the JBCS mail client doesn't do any processing with the mail, so there's no code to get attachments, etc.

                You can use writeMessage then create a ByteArrayInputStream which you can then use to create a MimeMessage object and go from there.

                I noticed that there's no "Content-Transfer-Encoding" handling in the JBoss code, so you'll needed to handle that. We're using MimeUtility.decode which is ok, but still have some issues with certain emails.

                Hope that helps!

                • 5. Re: sample code for getting message body & attachments
                  jhudson

                  Thank you very much for the reply.

                  I'm not a hard-core mail guy but need high quality code that can interpret the mail body and attachments. Is there anybody that would consider writing the code for a monetary amount? If so, what would you charge and would you accept a PayPal payment?

                  Basically, I'm not comfortable with my skills in this area to write the robust code that I desire and am willing to pay for it. Please respond to joe@binamics.com if anyone is interested. Thanks.

                  Joe

                  • 6. Re: sample code for getting message body & attachments
                    jhudson

                    Ok, new question.. same topic:

                    Is there any way I could convert a org.jboss.mail.message.MailBody to a javax.mail.Multipart. And, is this something that should be done or am I missing something? Please forgive if this is a stupid question. Thanks very much for any help!

                    Joe