How to read the message body in a mail

how can we read the message body of a mail. i am using pop3 server for reading the mails. my program is
public class GetMessageExample {
public static void main (String args[]) throws Exception {
String host = args[0];
String username = args[1];
String password = args[2];
Properties props = new Properties();
Session session = Session.getInstance(props, null);
Store store = session.getStore("pop3");
store.connect(host, username, password);
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
BufferedReader reader = new BufferedReader (
new InputStreamReader(System.in));
Message message[] = folder.getMessages();
for (int i=0, n=message.length; i<n; i++) {
System.out.println(i + ": " + message.getFrom()[0]
+ "\t" + message[i].getSubject());
System.out.println(
"Do you want to read message? [YES to read/QUIT to end]");
String line = reader.readLine();
if ("YES".equals(line)) {
message[i].writeTo(System.out);
} else if ("QUIT".equals(line)) {
break;
folder.close(false);
store.close();
i am getting the following exception
Exception in thread "main" java.lang.NoSuchFieldError: contentStream
at com.sun.mail.pop3.POP3Message.getContentStream(POP3Message.java:115)
at javax.mail.internet.MimePartDataSource.getInputStream(MimePartDataSou
rce.java:61)
at com.sun.mail.handlers.text_plain.getContent(text_plain.java:65)
at javax.activation.DataSourceDataContentHandler.getContent(DataHandler.
java:755)
at javax.activation.DataHandler.getContent(DataHandler.java:511)
at javax.mail.internet.MimeMessage.getContent(MimeMessage.java:1072)

The Part interface that the Message class implements describes 3 ways for getting the content of a message. To use an Input Stream, you can call the getInputStream() method on the message itself, rather than System.in.
Hope this helps!

Similar Messages

  • How to read the messages in the JMS Queue using JMX

    Hi,
              I want to read messages in the JMS queue using JMX. I was able to read using QueueBrowser but want to modify priority of the messages using JMX.
              I tried to use JMSDestinationRuntimeMBean but it does not allow us to read messages unless we pass the message Id. Is there any way that I can get all the messages in the queue.
              I am using Weblogic 8.1 SP4
              Can someone please help me in this regard.
              Thanks,
              Kiran.
              Edited by KGudipati at 10/22/2007 1:22 AM

    Hi,
    As far as i know, JMS Object Messages is not supported by XI JMS adapter.
    you need to have the JMS provider to transform the message to bytes messages.
    (Refer to SAP note 856346)

  • How to read the messages from the processed Batch session log

    Hi All,
    I am posting an accounting document through FB01 by submitting the report RFBIBL00 along with the file through which a Batch session gets generated in SM35.The Batch session is then processed by submitting the report RSBDCSUB. My code is as shown below:
    SUBMIT rfbibl00 WITH  ds_name = co_file_output
                      WITH callmode = co_batch AND RETURN.
    Process Batch session
      SUBMIT rsbdcsub
        WITH mappe = gv_name_jd
        WITH von   = sy-datlo
        WITH bis   = sy-datlo
         AND RETURN
    My requirement is to capture the document number from the log of the processed batch session. Can anyone suggest me how to go about this.
    Thanks in Advance,
    Vinay B

    Hi,
    check the routine read_bdc_log_plain in program rsbdc_protocol.
    get the data from table APQL and then use the logic.
            bapiret2-id = logtable-logmessage+74(16).
            bapiret2-number = logtable-logmessage+94(3).
            bapiret2-message_v1 = logtable-logmessage+100(20).
            CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL'
              EXPORTING
                id         = bapiret2-id
                number     = bapiret2-number
                textformat = 'ASC'
                message_v1 = bapiret2-message_v1
              IMPORTING
                message    = bapiret2-message.
            WRITE: (60) bapiret2-message.
    Edited by: Keshav.T on Apr 7, 2010 4:23 PM

  • How to send binary data in the message body

    How can we send binary data in the message body that is base64 encoded? below are the requirements
    Mime Header.
    Mime-version: 1.0
    Content-Type: application/octet_stream; name=test
    Content-Transfer-Encoding: Base64
    Submission must be named "test.sub" (lowercase)
    Submission must be base64 mime-encoded
    Submission must be sent in the body of the message (not as an attachment)
    Only one submission per mail message
    No other comments should be put in the body of the mail message (other than the submission)
    I highly appreciate your help. If you can provide few examples, that will be very helpfull.
    Thanks,
    Madan

    Use Message.setContent to set the content, or use Message.setDataHandler with
    a DataHandler constructed with a ByteArrayDataSource. If the content is not
    "naturally" encoded in base64, you can enforce it by setting the Content-Transfer-Encoding
    header to "base64". Any reasonable mail reader won't care what encoding you use, as
    long as the decoded data is correct.

  • HT2500 The message section of my Mail is very tiny to read as I type my messages.  How do I enlarge the viewing size of my window?

    The message section of my Mail is very tiny to read as I type my messages.  How do I enlarge the viewing size of my window?
    I am referring to outgoing new messages that I am typing.

    Can you drag the bottom right corner? You can in Snow Leopard, and I imagine you can in Lion.

  • There used to be a preview window in mail where you could read the message in the mail box but now its gone. It just shows me who its from and the date. I now have to click on the message twice to get it to display. How do I get the preview box back?

    There used to be a preview window in mail where you could read the message in the mail box but now its gone. It just shows me who its from and the date. I now have to click on the message twice to get it to display. How do I get the preview box back?

    There is a bug in Mail triggered by receiving a password-protected PDF as an attachment. According to reports, the bug is fixed in OS X 10.8.5.

  • How to read the error message like clipping positive or -ve in Tektronix oscillioscope 3012B

    During acquiring the Sine wave or triangular wave from TDS3012B, if the amplitude or Max or min is clipping, how do you read the error?  I used *ESR?, first time when I ran the error query program, it gave me Error message saying it is clipping, after that If I run again,the error query , It would not give me the error message, I couldn't reproduce it, eventhough but On the screen if I measure, Amp, min and Max it says that it is clipping positive or -ve. I was wondering how to read the error message while aquiring the data?  If any one could help me that would be of great help.. Thanks

    Usually, reading the error status register clears it. I'm not familiar with this particular model of scope but you may have to initiate a new acquisition in order for the scope to generate a new error. Another possiblity is that a new error will be generated when the vertical scale changes. Unless someone posts with an answer, I'd say that your best bet to get an answer is to contact Tektronix technical support.

  • How to read the multipart/realted mime type message.

    hello, sir
    please tell me,
    how to read the multipart/realted message.
    which are the subpart are included in the "multipart/related" message
    i know only "multipart/mixed" and i know how to read ,it contain the subpart ,
    1)text / plain
    2)text / html
    3)multipart/alternative
    a)text / plain
    but i don't know which are the subpart included in the "multipart/related " please tell me.
    thanks

    Today we rely on Simulink to perform parameterization of your designs in two ways:
    Parameterizable Subsystems and Blocks : Parameters themselves can be MATLAB expressions that need to be evaluated for which we need the MATLAB interpreter
    The very useful Rate and Type propagation or Simulink compilation that allows us to specify types & rates in one location that gets systematically propagated to all.
    To truly make the HDL Netlist that is generated from SysGen parameterizable, we would have to implement some of this capability in the HDL netlist itself by:
    Using Generics(VHDL) or Parameters(Verilog) - We would have to capture the bit width(type) propagation through levels of hierarchies and finally parameterize the IP itself based on this value
    Since IP itself does not have this capability through generics, we would have to package a separate tcl script that updates the IP parameterization appropriately in response to top level parameters(or GUI parameters)
    Interpreting MATLAB expressions and translating them into VHDL/Verilog expressions (alternatively tcl expressions of IP). In simulink, mask parameters can be passed from one level to the next. Also parameterization of a block can be composed of Matlab expressions using variables from ancestor masks & the MATLAB interpreter – so we will need to somehow capture that as well.
     

  • How to modify Exchange 2013 TXT(SMS) notifications to not include the subject line or any of the message body of emails

    We have a group of users who are not permitted to download/save any emails they receive onto public or personal devices, they are only allowed to log in manually and view their mail through OWA (I realize there are ways to use OWA to download mail, however
    the users are explicitly forbidden from doing this, and any countermeasures that can be put in place, are/will be).
    With our new Exchange 2013 server, it seems it has the built in capability to send TXT(SMS) notifications instantly when a user receives mail.  We would like to allow our users to utilize this feature, however currently, the notification includes not
    only the sender of the email, but also the subject line and part of the message body.  As it stands, we can't have this as part of the email would then be saved on their device.
    I am wondering if there is a way to modify Exchange 2013 to not include the subject or message body, so that our users could at least get an instant notification 1-that they have a new email and 2-who it's from?
    Any information would be appreciated, thanks!

    We can configure SMS Text Message Notification for various situation like Calendar notifications, Voice mail notifications, Email notifications if your user's Mailbox hosted in Exchange Server 2013
    To set up your phone to receive text messages when you want to have Calendar notifications, Voice mail notifications, Email notifications use the steps as follows
    Note: Text message fees are applicable and it will appear on your phone bill.
    Login to Outlook Web App, click Options > See All Options > Phone > Voice Mail tab.
         In the Notifications section, choose one of the following options:
    Calendar notifications... 
    Voice mail notifications... 
    Email notifications using an Inbox rule...
    Turn On Notification
    First step is to turn on the notification of text messaging. Click Turn on Notifications
    Select Setup Notification: Need to select your operator,
    It will request to provide your Mobile Operator.
    Note: As of now Exchange Server 2013 supports only the below list of operators.
    Locale: United State
    Mobile Operator: AT & T, Sprint PCS, T-Mobile, Verizon Wireless
    Locale: Canada,
    Mobile Operator:Bell Telus Mobility
    Locale: Romania
    Mobile Operator:Orange Romania
    Provide your telephone number. It will send you the passcode on your mobile number.
    Type the passcode for confirmation
    Calendar Notifications:
    On Selecting Calendar Notification: Select the option based upon your requirement.
    Email Notification Using Inbox Rule:
    Similarly for the text messaging for the email notification, select the option based upon your requirement and setup them up
    Exchange Queries

  • Help me...How to read the content if "Transfer-Encoding:chunked" is used?

    I am doing a project for internet control using Java,PHP and MySql.All sites should go through the proxy server only.If the HTTP header contains Content-Length,am getting the content length as below:
    public class HTTPResponseReader extends HTTPMessageReader
        String statusCode;
        public HTTPResponseReader(InputStream istream) throws IOException,                     NoSuchElementException
      BufferedInputStream distream = new BufferedInputStream(istream);
      retrieveHeader(distream);
      StringTokenizer st =  new StringTokenizer(new String(HTTPMessageReader.toArray(header)));
      versionProtocol = st.nextToken();
      statusCode = st.nextToken();
      String s;
      while (st.hasMoreTokens())
            s = st.nextToken();
            if (s.equals("Transfer-Encoding:"))
           transferEncoding = new String(st.nextToken());
         if (s.equals("Content-Length:"))
           contentLength = Integer.parseInt(st.nextToken());
         if (s.equals("Connection:"))
          connection = new String(st.nextToken());
          if (connection.equals("keep-alive")) mustCloseConnection = false;
       retrieveBody(distream);     
    }After getting the Content-Length,i used read method to read the content upto that content length.Then i concatenated the HTTP header and body and the requested site was opened.But some sites dont have Content-Length.Instead of that,Transfer-Encoding is used.I got the HTTP Response header as "Transfer-Encoding:chunked" for some sites.If this encoding is used how to get the length of the message body and how to read the content.
    Can anybody help me.
    Thanks in advance...
    Message was edited by:
    VeeraLakshmi

    Why don't you use HttpUrlConnection class to retrieve data from HTTP server? This class already supports chunked encoding...
    If you want to do anything by yourself then you need to read HTTP RFC and find all required information. Well in two words you may reject advanced encoding by specifying HTTP 1.0 in your request or download chunked answer manually. Read RFC anyway :)

  • When i go to send a new text, the text field isn't blank.  There is already text entered in the message body.

    When i go to send a new text, the text field isn't blank.  There is already text entered in the message body that I have to go in and delete before typing my new text.  this prevents me from forwarding anything through text because if I get something I wish to forward, selecting forward as an option always brings up the same junk just like when trying to send a new message.  How can i remedy this?

    Here it goes -
    1) Download iBackupBot: http://download.cnet.com/iBackupBot/3000-2141_4-10969873.html
    2) Plug phone into computer and run backup
    3) Use "Explorer" box to find Messages: HomeDomain/Library/SMS/Drafts/(null).draft/
    4) In "Null Drafts" there is a file "message.plist"
    5) Double click to open, (cancel the popup if you did not purchase the iBackupBot) and you will see the prepopulating message on the <string> line 6
    6) Delete the offending text, leave all code
    7) Close text editor
    8) Right click on message.plist file and select "Restore selected item(s) to device"
    9) File will be restored to your phone and it will restart itself.
    10) Voila! Now it is time to consider that Windows phone....:)

  • I can't see some of the message body

    Hi guys,
    When I open some messages in Microsoft Outlook 2003 I can't see some parts of the message body. With Outlook Express is all ok. We use Sun Java(tm) System Messaging Server 6.2 (built Dec 2 2004) with Messaging Express as webmail.
    The same problem is happening with Internet Explorer 6 and 7.
    I don't know how to get out from this problem beacuse 50% of our users use Outlook Express or Microsoft Outlook.
    Please help!

    cobe wrote:
    Hi guys,
    When I open some messages in Microsoft Outlook 2003 I can't see some parts of the message body. This is very vague. What does 'some messages' mean. What is different about these messages compared to the other messages that do work e.g. size, age, attachments, forwarded, replied, application that sent the email (e.g. webmail/another email client), MIME structure etc.
    What does 'some parts' mean? You cannot read the text/html/attachments/multipart alternate parts etc?
    With Outlook Express is all ok. We use Sun Java(tm) System Messaging Server 6.2 (built Dec 2 2004) with Messaging Express as webmail. This is clearly an old version. What OS are you running (please supply ./imsimta version output in future)?
    There are known bugs with Outlook handling of certain emails that we output in earlier 6.2 releases e.g.
    bug# 2129307 - "Outlook is unable to display all content in replies from IMS that contain nested"
    The same problem is happening with Internet Explorer 6 and 7.Not sure what this means. IE is a web-browser not an email client.
    I don't know how to get out from this problem beacuse 50% of our users use Outlook Express or Microsoft Outlook.I would suggest step (1) is to patch your messaging server installation.
    Regards,
    Shane.

  • How to delete the messages in the purges folder?

    if the mailbox is enabled the single item recovery, then the messages would move from deletion folder to the purges folder After running the following script,
    Search-Mailbox dave -searchdumpsteronly
    -deletecontent
    so my question is how to delete the messages in the purges folder with some script or retention policy?
    Please click the Mark as Answer button if a post solves your problem!

    Thank you all,
    As the mailbox is enabled single item recovery.
    I just want to make the items neither in deletion folder, nor in purges folder.
    So I think there are two ways to achieve this.
    Method 1,disabled the single item recovery. then delete the items in deletion folder ,so it wouldn't enter to the purges folder, it just deleted permanently. then enable the single item recovery
    Method 2,delete the items in deletion folder,then the messages move to the purges folder, then delete the messages in purges folder.
    the Method 1 is not so good ,as it need to disable the single item recovery firstly, then enable  single item recovery .
    So I want to use the Method 2
    Please click the Mark as Answer button if a post solves your problem!

  • How to print the message in 2 lines?

    How to print the message in 2 lines?
    Here i am having it like this... MESSAGE i000(zm) WITH lv_uname.
    here I want to print lv_uname in 2 lines because it lengthy one.
    Thanks,
    Sridhar.

    No man, itas not comming..I am using the below logic to print my message:
        CONCATENATE text-I01 lv_printdate1 text-I02 INTO lv_printname
    SEPARATED BY space.
        MESSAGE i002(zm) WITH lv_printname.
    its printing in a single line...

  • How to Customize the Message "No Row Returned" from a Report

    Hi,
    I've been trying to customize the Message "No Row Returned" from a Report.
    First i followed the instructions in Note:183131.1 -
    How to Customize the Message "No Row Returned" from a Report
    But of course the OWA_UTIL.REDIRECT_URL in this solution did not work (in a portlet) and i found the metalink document 228620.1 which described how to fix it.
    So i followed the "fix" in the document above and now my output is,..
    "Portlet 38,70711 responded with content-type text/plain when the client was requesting content-type text/html"
    So i search in Metalink for the above and come up with,...
    Bug 3548276 PORTLET X,Y RESPONDED WITH CONTENT-TYPE TEXT/PLAIN INSTEAD OF TEXT/HTML
    And i've read it and read it and read it and read it and can't make heads or tails of what it's saying.
    Every "solution" seems to cause another problem that i have to fix. And all i want to do is customize the Message "No Row Returned" from a Report. Please,...does anyone know how to do this?

    My guess is that it only shows the number of rows it has retrieved. I believe the defailt is for it to only retrieve 50 rows and as you page through your report it retrieves more. So this would just tell you how many rows was retireved, but probably not how many rows the report would contain if you pages to the end. Oracle doesn't really have a notion of total number of rows until the whole result set has been materialized.

Maybe you are looking for

  • Ad-Hoc Query: no of hits???

    Hi, For Ad-hoc query, I encountered the below "strange" case: (1) When I click on "Hit List" button -> indicates 8033. However, when I click on the "glasses" button, it indicates 750 hits. IF I click on "Hit List" button again, it will indicate 7979?

  • Can I move address bar to different location?

    IE allows me to drag address bar to another location (up to menu bar or down). I am assuming this it NOT possible in Firefox? Please confirm. P.S. I'm using Firefox 3.6.12. Cannot upgrade because I'm on dial-up and my web booster does not support lat

  • When I go into settings to make any changes, I am presented with an administrators name and password, what would they be?

         When I go into settings to make any changes local on the Mac, I am presented with and Administrators' name and password.  Before, it only presented a password, would anyone happen to know what the username is?

  • Viewing completed forms on iPad

    I have several people who I work with that are having issues with viewing a form they have filled out on an iPad.  When they open it on a Mac or PC, they can view what they have filled out.  But, when they open it either from the Dropbox App or Adobe

  • Triggering a GigE camera

    Newbie question for you all.  Hope this makes sense: At the moment, we are using a Dalsa area scan camera and a NI PCI-1424 frame-grabber with a parallel digital interface.  We use LabVIEW and IMAQ software.  Our software creates an IMAQ session that