DataHandler Exception

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

DataHandler Exception

Postby upensabnis » Sat Oct 04, 2008 8:14 am

I want 2 send mail to gmail server.......I'm getting DataHandler exception in my send mail module.....i hv downloaded latest activation.jar .........I'm also facing problem in displaying mails which r of Mime type.......if ne 1 nos den plz guide us.........
upensabnis
Junior Developer
Junior Developer
 
Posts: 18
Joined: Wed Jul 16, 2008 5:12 pm

Top

Postby plusminus » Sat Oct 04, 2008 2:36 pm

*activating telepathic skills*
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby ninor » Sun Oct 05, 2008 12:17 am

plusminus wrote:*activating telepathic skills*

LOL

Please upensabnis, extend your explanation a lil bit...
Image AndDev: Your Android Development Community / Tutorials | Here's my Basic ToolKit
User avatar
ninor
Moderator
Moderator
 
Posts: 180
Joined: Thu Aug 14, 2008 6:30 pm
Location: Barcelona, Spain

Postby upensabnis » Mon Oct 06, 2008 8:20 am

IMapClient.java handles all javamail connection & returns String array..........I m getting DataHandler Exception due to calling message[i].getContent().toString() method or even for message[i].getDatHandler() method......All other methods like getSubject() are working fine......I hv created IMapClient obj in another file which calls getMail() method.....


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package out.exp;
  2.  
  3.  
  4.  
  5. import java.io.IOException;
  6.  
  7. import java.security.Security;
  8.  
  9.  
  10.  
  11. import javax.activation.DataHandler;
  12.  
  13. import javax.mail.Folder;
  14.  
  15. import javax.mail.Message;
  16.  
  17. import javax.mail.MessagingException;
  18.  
  19. import javax.mail.Session;
  20.  
  21. import javax.mail.Store;
  22.  
  23. public class IMapClient
  24.  
  25. {
  26.  
  27.         static
  28.  
  29.         {
  30.  
  31.                 Security.addProvider(new org.apache.harmony.xnet.provider.jsse.JSSEProvider());
  32.  
  33.         }
  34.  
  35.  
  36.  
  37.         public static String [] getMail() throws MessagingException,IOException
  38.  
  39.         {
  40.  
  41.                 java.util.Properties props = new java.util.Properties();
  42.  
  43.                 props.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
  44.  
  45.                 props.setProperty("mail.imap.socketFactory.fallback", "false");
  46.  
  47.                 props.setProperty("mail.imap.socketFactory.port", "993");
  48.  
  49.  
  50.  
  51.                 Session session = Session.getDefaultInstance(props);
  52.  
  53.  
  54.  
  55.                 Store store = session.getStore("imap");
  56.  
  57.                 store.connect("imap.gmail.com", "outlook.project", "outlookproject");
  58.  
  59.  
  60.  
  61.                 Folder folder = store.getFolder("INBOX");
  62.  
  63.                 folder.open(Folder.READ_ONLY);
  64.  
  65.  
  66.  
  67.                 Message[] message = folder.getMessages();
  68.  
  69.                 String [] titles = new String[message.length];
  70.  
  71.                 for (int i=0, n = message.length; i < n; i++)
  72.  
  73.                 {
  74.  
  75.                         if(message[i].isMimeType("TEXT/PLAIN") || message[i].isMimeType("multipart/ALTERNATIVE"))
  76.  
  77.                         {
  78.  
  79.                                 titles[i] = message[i].getContent().toString();
  80.  
  81.                         }
  82.  
  83.                 }
  84.  
  85. // Close connection
  86.  
  87.                 folder.close(false);
  88.  
  89.                 store.close();
  90.  
  91.                 return titles;
  92.  
  93.         }
  94.  
  95. }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


I m using android-sdk m5-rc15 for windows........can it b a SDK version problem??or activation.jar version is not appropriate??plzz help.......
upensabnis
Junior Developer
Junior Developer
 
Posts: 18
Joined: Wed Jul 16, 2008 5:12 pm

Postby plusminus » Mon Oct 06, 2008 2:02 pm

You should definitely be using the latest SDK (1.0) or you problems will grow over time and less people will be able to help you.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby upensabnis » Mon Oct 06, 2008 6:47 pm

thank you plusminus for the reply....
but i have downloaded even the latest version of sdk ie 1.0..... nd tried the same above mentioned code on it.... but even then i'm getting org.apache.android.mail exception..... also there is no org.apache.harmony package in the latest version which is a security provider....
upensabnis
Junior Developer
Junior Developer
 
Posts: 18
Joined: Wed Jul 16, 2008 5:12 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 6 guests