Javamail and dependancies from AWT

Put your problem here if it does not fit any of the other categories.

Javamail and dependancies from AWT

Postby lucabelluccini » Thu May 22, 2008 4:10 pm

Hi... I am developing a Mail Client and now my App is able to show mails coming from IMAP or POP3 account.
I am using Sun Javamail or GNU Javamail (the code works for both libraries).
Searching on the internet, I realized that Javamail needs a little part of AWT (DataFlavor class and other stuff).
But I know that there are still some issues on the
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. getContent()
  2.  
  3.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

method. It is always returning a Object which is instance of some InputStream, instead of Part/Multipart one.
I solved some troubles with Multipart using
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. if( part.getContentType().toLowerCase().startsWith("multipart") ){
  2.  
  3.                 MimePartDataSource mMPDS = new MimePartDataSource( (MimePart) part);
  4.  
  5.                 Multipart mpart = new MimeMultipart( mMPDS );                  
  6.  
  7.                 for( int mpc = 0; mpc < mpart.getCount(); mpc++ ){
  8.  
  9.                         Part tempBP = mpart.getBodyPart(mpc);
  10.  
  11.                         recursiveExtract(tempBP);
  12.  
  13.                 }
  14.  
  15.                 return;
  16.  
  17.         }
  18.  
  19.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

But in certain cases (for example QUOTED-PRINTABLE Bodyparts), my code doesn't work.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.     private void recursiveExtract(final Part part) throws MessagingException, IOException {
  2.  
  3.        
  4.  
  5.         Log.v("Mail Android","part Content-Type: " + part.getContentType());
  6.  
  7.         Object x = part.getContent();
  8.  
  9.         Log.v("Mail Android","part Class: " + x.getClass().toString());
  10.  
  11.        
  12.  
  13.         if( part.getContentType().toLowerCase().startsWith("text/plain")) {
  14.  
  15.                 try {
  16.  
  17.                         if( !part.getDisposition().equals(Part.ATTACHMENT)) {
  18.  
  19.                                 this.inlines.add( createInline(part) );
  20.  
  21.                                 return;
  22.  
  23.                         }
  24.  
  25.                         } catch (Exception e) {
  26.  
  27.                                 // TODO EXCEPTION HANDLING
  28.  
  29.                                 e.printStackTrace();
  30.  
  31.                         }
  32.  
  33.         }
  34.  
  35.         if( part.getContentType().toLowerCase().startsWith("text/html")) {
  36.  
  37.                 try {
  38.  
  39.                         if( !part.getDisposition().equals(Part.ATTACHMENT)) {
  40.  
  41.                                 this.inlines.add( createInline(part) );
  42.  
  43.                                 return;
  44.  
  45.                         }
  46.  
  47.                         } catch (Exception e) {
  48.  
  49.                                 // TODO EXCEPTION HANDLING
  50.  
  51.                                 e.printStackTrace();
  52.  
  53.                         }
  54.  
  55.         }
  56.  
  57.         if( part.getContentType().toLowerCase().startsWith("multipart") ){
  58.  
  59.                 MimePartDataSource mMPDS = new MimePartDataSource( (MimePart) part);
  60.  
  61.                 Multipart mpart = new MimeMultipart( mMPDS );                  
  62.  
  63.                 for( int mpc = 0; mpc < mpart.getCount(); mpc++ ){
  64.  
  65.                         Part tempBP = mpart.getBodyPart(mpc);
  66.  
  67.                         recursiveExtract(tempBP);
  68.  
  69.                 }
  70.  
  71.                 return;
  72.  
  73.         }
  74.  
  75.        
  76.  
  77.         this.attachments.add( createAttachment(part) );
  78.  
  79.     }
Parsed in 0.039 seconds, using GeSHi 1.0.8.4


I know that DataFlavor returns InputStream as default if content is not "understood". So, it is an AWT recognising issue?
lucabelluccini
Freshman
Freshman
 
Posts: 6
Joined: Thu May 22, 2008 3:58 pm
Location: Turin

Top

Postby lucabelluccini » Tue May 27, 2008 10:12 pm

SOLVED.

As soon as possible I'll publish a multi-account mail client.
lucabelluccini
Freshman
Freshman
 
Posts: 6
Joined: Thu May 22, 2008 3:58 pm
Location: Turin

Sending Email with android 0.9

Postby faiz.india » Mon Sep 15, 2008 8:05 am

Hi,
I am trying to implement sending email functionality, I have added "javax.mail" and "javax.activation" jar to the build path. When i try to send an email i get "VerifyError". I dont know how to tackle this problem.

If any one has any idea, do let me know.


Thanks and Regards,
Faiz.


lucabelluccini wrote:SOLVED.

As soon as possible I'll publish a multi-account mail client.
faiz.india
Developer
Developer
 
Posts: 32
Joined: Mon Jul 28, 2008 12:21 pm
Location: Pune - India

Postby lucabelluccini » Mon Sep 15, 2008 10:26 am

Send me a message if you need some help with JavaMail.
I ported it for Android platform.
lucabelluccini
Freshman
Freshman
 
Posts: 6
Joined: Thu May 22, 2008 3:58 pm
Location: Turin

Sending Email with android 0.9

Postby faiz.india » Mon Sep 15, 2008 10:41 am

I am using android 0.9, i have set up JAMES Mail Server, 2 SUN API's mail.jar and activation.jar and have a small java class for sending email that works fine.

Now, my main concern is to use the same java program and 2 SUN API's for sending email in my android application.
faiz.india
Developer
Developer
 
Posts: 32
Joined: Mon Jul 28, 2008 12:21 pm
Location: Pune - India

Sending Email with android 0.9

Postby faiz.india » Mon Sep 15, 2008 10:51 am

I am using android 0.9, i have set up JAMES Mail Server, 2 SUN API's mail.jar and activation.jar and have a small java class for sending email that works fine.

Now, my main concern is to use the same java program and 2 SUN API's for sending email in my android application.

I added SUN API's to build path and ran the application, on sending of email the application gave a runtime exception "VerifyError"

Were you able to send email with SDK 0.9 using SUN API's
faiz.india
Developer
Developer
 
Posts: 32
Joined: Mon Jul 28, 2008 12:21 pm
Location: Pune - India

Top

api problems

Postby upensabnis » Mon Sep 22, 2008 12:14 pm

hi lucabelluccini,
even i'm doing an email client. i want to connect to gmail server. so can you please guide me for the same. i mean i know that i will be using javamail. but i dont know how to add it in android library.
thanx in advance...
upensabnis
Junior Developer
Junior Developer
 
Posts: 18
Joined: Wed Jul 16, 2008 5:12 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 14 guests