Hello,
I used Oracle JavaMail 1.4.4 + Oracle JAF 1.1.1 and additional.jar (javax.awt dependencies replacement) from [url http://code.google.com/p/javamail-android/] javamail-android
Me neither sounds good, but the only way I found to make it work, for the time being sent without problems.
But I have a problem retrieving attachments, and that is the code that I used before, now is not Mutipart instance.
This is the code:
SubjectTerm term = new SubjectTerm("[aNAME]");
messages = inbox.search(term);
messages = ufolder.getMessagesByUID(1, UIDFolder.LASTUID);
// FetchProfile
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
fp.add(FetchProfile.Item.FLAGS);
fp.add("X-Mailer");
inbox.fetch(messages, fp);
for (int n = 0; n < messages.length; n++)
{
message = messages[n];
uid = ufolder.getUID(message);
messagecontentObject = message.getContent();
if (messagecontentObject instanceof Multipart)
{
When it comes to:
messagecontentObject = message.getContent();
if (messagecontentObject instanceof Multipart)
this is null (messagecontentObject) therefore can not go inside the if statement
This a debug trace:
12-27 19:39:44.419: I/System.out(4941): DEBUG: setDebug: JavaMail version 1.4.4
12-27 19:39:44.419: I/System.out(4941): DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc.,1.4.4]
12-27 19:39:44.429: I/System.out(4941): DEBUG: mail.imap.fetchsize: 16384
12-27 19:39:44.429: I/System.out(4941): DEBUG: mail.imap.statuscachetimeout: 1000
12-27 19:39:44.429: I/System.out(4941): DEBUG: mail.imap.appendbuffersize: -1
12-27 19:39:44.429: I/System.out(4941): DEBUG: mail.imap.minidletime: 10
12-27 19:39:44.429: I/System.out(4941): DEBUG: trying to connect to host "imap.gmail.com", port 993, isSSL false
12-27 19:39:44.759: D/dalvikvm(4941): GC_CONCURRENT freed 454K, 53% free 2849K/5959K, external 1019K/1531K, paused 4ms+5ms
12-27 19:39:45.069: I/System.out(4941): * OK Gimap ready for requests from 78.107.207.948 ez12if16855419wid.4
12-27 19:39:45.069: I/System.out(4941): A0 CAPABILITY
12-27 19:39:45.169: I/System.out(4941): * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH
12-27 19:39:45.169: I/System.out(4941): A0 OK Thats all she wrote! ez11if16255419wid.4
12-27 19:39:45.169: I/System.out(4941): DEBUG IMAP: AUTH: XOAUTH
12-27 19:39:45.169: I/System.out(4941): DEBUG: protocolConnect login, host=imap.gmail.com, user=myuser@gmail.com, password=<non-null>
12-27 19:39:45.179: I/System.out(4941): A1 LOGIN myuser@gmail.com myuser01
12-27 19:39:45.401: I/System.out(4941): * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE
12-27 19:39:45.401: I/System.out(4941): A1 OK myuser@gmail.com Bob Esponja authenticated (Success)
12-27 19:39:45.401: I/System.out(4941): A2 CAPABILITY
12-27 19:39:45.509: I/System.out(4941): * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE
12-27 19:39:45.509: I/System.out(4941): A2 OK Success
12-27 19:39:45.529: I/System.out(4941): A3 LIST "" INBOX
12-27 19:39:45.639: I/System.out(4941): * LIST (\HasNoChildren) "/" "INBOX"
12-27 19:39:45.639: I/System.out(4941): A3 OK Success
12-27 19:39:45.639: I/System.out(4941): DEBUG: connection available -- size: 1
12-27 19:39:45.639: I/System.out(4941): A4 SELECT INBOX
12-27 19:39:45.769: I/System.out(4941): * FLAGS (\Answered \Flagged \Draft \Deleted \Seen $Forwarded NonJunk)
12-27 19:39:45.769: I/System.out(4941): * OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen $Forwarded NonJunk \*)] Flags permitted.
12-27 19:39:45.769: I/System.out(4941): * OK [UIDVALIDITY 659007327] UIDs valid.
12-27 19:39:45.769: I/System.out(4941): * 3 EXISTS
12-27 19:39:45.769: I/System.out(4941): * 0 RECENT
12-27 19:39:45.769: I/System.out(4941): * OK [UIDNEXT 50] Predicted next UID.
12-27 19:39:45.769: I/System.out(4941): A4 OK [READ-WRITE] INBOX selected. (Success)
12-27 19:39:45.779: I/System.out(4941): A5 SEARCH SUBJECT [AppName] ALL
12-27 19:39:45.902: I/System.out(4941): * SEARCH 1 2 3
12-27 19:39:45.902: I/System.out(4941): A5 OK SEARCH completed (Success)
12-27 19:39:45.902: I/System.out(4941): A6 UID FETCH 1:* (UID)
12-27 19:39:46.019: I/System.out(4941): * 1 FETCH (UID 47)
12-27 19:39:46.039: I/System.out(4941): * 2 FETCH (UID 48)
12-27 19:39:46.069: I/System.out(4941): * 3 FETCH (UID 49)
12-27 19:39:46.089: I/System.out(4941): A6 OK Success
12-27 19:39:46.099: D/dalvikvm(4941): GC_CONCURRENT freed 453K, 53% free 2838K/5959K, external 1019K/1531K, paused 4ms+7ms
12-27 19:39:46.109: I/System.out(4941): A7 FETCH 1:3 (ENVELOPE INTERNALDATE RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (X-Mailer)])
12-27 19:39:46.259: I/System.out(4941): * 1 FETCH (RFC822.SIZE 31979 INTERNALDATE "27-Dec-2011 16:44:33 +0000" FLAGS (\Seen) ENVELOPE ("Tue, 27 Dec 2011 16:44:17 +0000 (GMT+00:00)" "[AppName] Prueba01" ((NIL NIL "user" "mydomain.com")) ((NIL NIL "user" "mydomain.com")) ((NIL NIL "user" "mydomain.com")) ((NIL NIL "myuser" "gmail.com")) NIL NIL NIL "<1156679744.3.1325004257360.JavaMail.javamailuser@localhost>") BODY[HEADER.FIELDS (X-Mailer)] {4}
12-27 19:39:46.259: I/System.out(4941):
12-27 19:39:46.259: I/System.out(4941):
12-27 19:39:46.259: I/System.out(4941): )
12-27 19:39:46.259: I/System.out(4941): * 2 FETCH (RFC822.SIZE 6817 INTERNALDATE "27-Dec-2011 16:49:59 +0000" FLAGS (\Seen) ENVELOPE ("Tue, 27 Dec 2011 16:49:05 +0000 (GMT)" "[AppName] test1" ((NIL NIL "user" "mydomain.com")) ((NIL NIL "user" "mydomain.com")) ((NIL NIL "user" "mydomain.com")) ((NIL NIL "myuser" "gmail.com")) NIL NIL NIL "<1079240688.1.1325004546463.JavaMail.javamailuser@localhost>") BODY[HEADER.FIELDS (X-Mailer)] {4}
12-27 19:39:46.259: I/System.out(4941):
12-27 19:39:46.259: I/System.out(4941):
12-27 19:39:46.259: I/System.out(4941): )
12-27 19:39:46.269: I/System.out(4941): * 3 FETCH (RFC822.SIZE 8063 INTERNALDATE "27-Dec-2011 16:51:14 +0000" FLAGS (\Seen) ENVELOPE ("Tue, 27 Dec 2011 16:50:21 +0000 (GMT)" "[AppName] test2" ((NIL NIL "user" "mydomain.com")) ((NIL NIL "user" "mydomain.com")) ((NIL NIL "user" "mydomain.com")) ((NIL NIL "myuser" "gmail.com")) NIL NIL NIL "<1079847320.3.1325004621240.JavaMail.javamailuser@localhost>") BODY[HEADER.FIELDS (X-Mailer)] {4}
12-27 19:39:46.269: I/System.out(4941):
12-27 19:39:46.269: I/System.out(4941):
12-27 19:39:46.269: I/System.out(4941): )
12-27 19:39:46.269: I/System.out(4941): A7 OK Success
12-27 19:39:46.279: I/System.out(4941): A8 FETCH 1 (BODYSTRUCTURE)
12-27 19:39:46.409: I/System.out(4941): * 1 FETCH (BODYSTRUCTURE (("APPLICATION" "OCTET-STREAM" ("NAME" "video.mp4") NIL NIL "BASE64" 30324 NIL ("ATTACHMENT" ("FILENAME" "video.mp4")) NIL)("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 0 0 NIL NIL NIL) "MIXED" ("BOUNDARY" "----=_Part_2_1157256384.1325004257065") NIL NIL))
12-27 19:39:46.409: I/System.out(4941): A8 OK Success
12-27 19:39:46.409: I/System.out(4941): A9 FETCH 2 (BODYSTRUCTURE)
12-27 19:39:46.549: I/System.out(4941): * 2 FETCH (BODYSTRUCTURE (("APPLICATION" "OCTET-STREAM" ("NAME" "video.mp4") NIL NIL "BASE64" 5172 NIL ("ATTACHMENT" ("FILENAME" "video.mp4")) NIL)("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 0 0 NIL NIL NIL) "MIXED" ("BOUNDARY" "----=_Part_0_1079182336.1325004545751") NIL NIL))
12-27 19:39:46.549: I/System.out(4941): A9 OK Success
12-27 19:39:46.549: I/System.out(4941): A10 FETCH 3 (BODYSTRUCTURE)
12-27 19:39:46.682: I/System.out(4941): * 3 FETCH (BODYSTRUCTURE (("APPLICATION" "OCTET-STREAM" ("NAME" "video.mp4") NIL NIL "BASE64" 6420 NIL ("ATTACHMENT" ("FILENAME" "video.mp4")) NIL)("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 0 0 NIL NIL NIL) "MIXED" ("BOUNDARY" "----=_Part_2_1079188064.1325004621148") NIL NIL))
12-27 19:39:46.682: I/System.out(4941): A10 OK Success
12-27 19:39:46.689: I/System.out(4941): A11 CLOSE
12-27 19:39:46.819: I/System.out(4941): A11 OK Returned to authenticated state. (Success)
12-27 19:39:46.819: I/System.out(4941): DEBUG: added an Authenticated connection -- size: 1
12-27 19:39:46.819: I/System.out(4941): A12 LOGOUT
12-27 19:39:46.939: I/System.out(4941): * BYE LOGOUT Requested
12-27 19:39:46.939: I/System.out(4941): A12 OK 73 good day (Success)
12-27 19:39:46.939: I/System.out(4941): DEBUG: IMAPStore connection dead
12-27 19:39:46.939: I/System.out(4941): DEBUG: IMAPStore cleanup, force false
12-27 19:39:46.939: I/System.out(4941): DEBUG: IMAPStore cleanup done
Please, somebody could give me a clue as to why the content of the message is null?.
Thanks in advance
Best regards