🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7568

Problems with javax.mail

#7568
From: S�ren Hanisch
Date: Fri, 08 Jun 2001 06:39
57 lines
2380 bytes
Hi,

some days before I asked how to fetch the attachment of a mail - Thanks to
the one who helped me.

New Problem:
Getting the attachments with Multipart is not a problem anymore as long the
mail has no empty body, but if so, the creation of a Multipart object from
that mail fails. How can I fetch the attachment although I can't create a
Multipart of such a mail. Here's my code:

Properties props = System.getProperties();
Session session = Session.getDefaultInstance(props,null);

       try {
           store = session.getStore("imap");
           store.connect(sMailserver,
                                + sOS_User
                                + "/"
                                + sMailaccIn,
                                sOS_Passwd);

          folder = store.getDefaultFolder();
          folder = folder.getFolder("INBOX");
          ufolder = (UIDFolder) folder;
          folder.open(Folder.READ_WRITE);


          msg = ufolder.getMessagesByUID(1,UIDFolder.LASTUID);
          if (msg.length>0) {

              for (int i=0;i<msg.length;i++) {

                          Multipart multipart = (Multipart)
msg[i].getContent(); // Here it fails if the

mail has an empty

body but an

existing attachment.

              }
          }

           folder.expunge();
           store.close();

       }
       catch (Exception f) {
          f.printStackTrace();
       }


Thanks for help

S�ren
Technical Details
Message-ID: <3b20733f@news.gwi-ag.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews!news.gwi-ag.com!172.25.33.81

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f74b3,4d4b35c5dbf41e2e,start
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-06-07 23:43:04 PST
From: "S�ren Hanisch" <soeren.hanisch@gwi-ag.com>
Newsgroups: borland.public.jbuilder.java.language
Subject: Problems with javax.mail
Date: Fri, 8 Jun 2001 08:39:56 +0200
Lines: 59
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
X-Original-NNTP-Posting-Host: 172.25.33.81
Message-ID: <3b20733f@news.gwi-ag.com>
NNTP-Posting-Host: 62.159.82.50
X-Trace: dnews 991982379 62.159.82.50 (7 Jun 2001 23:39:39 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews!news.gwi-ag.com!172.25.33.81