Results 1 to 2 of 2
  1. #1
    sneakyhippie is offline Member
    Join Date
    Apr 2010
    Posts
    2
    Rep Power
    0

    Default JavaMail POP3Message.getSize() problem

    I am using the getSize() method for the POP3Message object to get the size of the message. I noticed the size returned from the method getSize() is not the same is what is returned from the LIST command. And in some cases is off by like 600 bytes. I understand that the docs say that the size may not be exact but I would expect that the JavaMail API would at least tell me whatever the POP3 protocol returns from the command. Has anyone else noticed this problem and know of a work around to getting the size that the LIST command actually returns?

    I'm using JavaMail 1.4 btw.

  2. #2
    sneakyhippie is offline Member
    Join Date
    Apr 2010
    Posts
    2
    Rep Power
    0

    Default

    Ok, I think I solved my own problem. Thought I would share.

    Basically I used the POP3Folder.listCommand() which executes the LIST command with no arguments. (I couldn't find how to pass an argument to the LIST command) This will return a list of all the messages and their sizes in the form of an InputStream. I then read the stream into a String and parsed the string with StringTokenizer and found the size associated with the message number I was looking for. Getting the size this way will not only give the "correct" POP3 size but also not call the TOP command and pull down the entire header...which apparently the POP3Message.getSize() method calls before it calls the LIST command even though it is unnecessary. Ofcourse if there are a lot of messages on the server this may not be saving you much data transfer since JavaMail won't let you pass the LIST command an argument and have to pull down the entire list.

Similar Threads

  1. JavaMail API
    By eponcedeleon in forum Advanced Java
    Replies: 1
    Last Post: 02-28-2010, 12:39 AM
  2. JavaMail Jar
    By rummy in forum Advanced Java
    Replies: 1
    Last Post: 01-21-2010, 03:51 PM
  3. Replies: 4
    Last Post: 03-21-2009, 11:43 PM
  4. [SOLVED] JavaMail Authentication Problem
    By frost750 in forum New To Java
    Replies: 1
    Last Post: 02-06-2009, 04:02 PM
  5. Javamail
    By v_mallikarjun in forum Advanced Java
    Replies: 14
    Last Post: 04-18-2008, 07:32 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •