How to Extract the content of a message?

Friends...My Message contains both body and attachments...
But while extracting, it returns content (body text) as null..but body is there..
attachments are coming properly...
If attachments are not there, it display the content properly..
im giving my code please check what s problem in that? please...
Object obj = msg.getContent();
if (msg.isMimeType("multipart/*"))
             Multipart multipart = (Multipart) obj;
             int       count     = multipart.getCount();
             for (int j = 0; j < count; j++)
                    Part        part = multipart.getBodyPart(j);
                    String      sct  = part.getContentType();
                    ContentType ct   = new ContentType(sct);
                    if (ct.match("text/plain") || ct.match("text/html"))
                        System.out.println("The content is " + (String)part.getContent());
                    String disposition = part.getDisposition();
                    if ((disposition != null)
                            && (disposition.equals(Part.ATTACHMENT)))
                        System.out.println("File Name is " + part.getFileName());
Sandhya Komali

Your mail server could be broken. What protocol are are using -
pop3 or imap? What server (what vendor) are you using?
Can you post the protocol trace when accessing
such a message?
Also, you might consider using the Part.isMimeType method
instead of ContentType.match, it will make your code simpler
(but is unrelated to your problem).

Similar Messages

  • How to extract the content of a mail message?

    Friends,,,
    How to extract the content of a mail message?
    the message does not contain any attachments or images.
    its just a plain text..
    if i use message.getContent(), in addition of the content it returns headers information also...
    but i need only the content of that message...
    if i write code like this:
    String content = (String) message.getContent();
    it gives cast exception...
    if the message contains only plain text, no multipart, then which method is useful to extract only the content?
    please tell me friends..
    thanks in advannce,
    regards,
    Venkata Naveen

    Message.getContent() does not return headers for a simple text/plain
    message. If you're getting headers, something else is wrong.
    Also, casting the result to String should work.
    Most likely the message really isn't a simple text/plain message.
    Provide more details and we'll help you figure out what you're
    doing wrong.
    Also, please read the msgshow.java demo program included with JavaMail.

  • How to extract the contents of the Jar file?

    Hello,
    Can anyone tell me how to extract the contents of the Jar file?
    An example will be highly appreciated.
    Thanks.

    From command line, or from within a java application?
    Kaj
    Btw. Why do you need to do it. You do know that you can add jars to the classpath and read resources from them without extracting the file?

  • How to extract the contents of ZIP file stored in oracle database column ?

    The file is in ZIP format and it is stored in BLOB databse column . The contents of file is in binary format .
    How to extract those contents from file and thus creating the same ZIP file as output in ODI ?
    Thanks
    Arun

    Perhaps you can something like what is described in the support note "How To Load A PDF File Or Other Binary Files To a BLOB Column From ODI (Doc ID 1412753.1)"

  • How to extract the content of a user uploaded txt file in web dynpro?

    Hi,
    I'm working on a java web dynpro component. This component consists of document upload field, where users should be able to upload .txt documents. These uploaded text documents should then be somehow read, and thir content displayed. I am already able to upload documents using the upload field, and store it in the context, but I'm still not able to extract the content of these text documents for displaying.
    Does anyone have any suggestions of how I could do this?
    Any help will be greatly appreciated!
    Thanks!

    Hi Alain,
        You can do through this document on how to upload/download files in Webdynpro.
    [https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/202a850a-58e0-2910-eeb3-bfc3e081257f]
    Once you have the uploaded file in your context if you are storing it as a byte array then convert it to a string using the String constructor String(byte[] bytes)  and then you can store this string in an attribute of type String which could be bound to a UI element (TextArea) to display the contents.
    If you are using an IWDResource then you will get an inputstream from which you can read the data and convert it to a string for display as mentioned above.
    Hope this helps.
    Sanyev

  • How to extract the content of a section using VBA?

    For example, I have an article like this:
    Abstract
    AbstractParagraph1
    AbstractParagraph2
    Body
    BodyParagraph1
    BodyParagraph2
    Reference
    ReferenceParagraph1
    ReferenceParagraph2
    Knowing that Abstract, Body and Reference are all headings, which means if I click the triangle button on the left of the heading (For example, Abstract), AbstractParagraph1 AbstractParagraph2 will shrink or expand. So my question is: how to retrieve the paragraph
    in a specific section using VBA?

    Hi UW,
    >> how to retrieve the paragraph in a specific section using VBA?
    In my option, you could use the Section Object (Word) to get the section object, and then use the Section.Range Property (Word) to get the content of the special section. The links below might be useful to you.
    # Section Object (Word)
    https://msdn.microsoft.com/en-us/library/office/ff194295.aspx
    # Section.Range Property (Word)
    https://msdn.microsoft.com/en-us/library/office/ff836097.aspx
    Best Regards,
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • How to extract the contents fo .xsl files

    wanna source code to extract and Modify the contents of .xsl files

    Duplicate of http://forum.java.sun.com/thread.jspa?threadID=635711&tstart=0

  • How to extract the actual XML document from soap message?

    My problem is " how to extract the actual XML document from soap message? "
    i just want to extract the attachment i.e. (pure XML document without any soap header or envolope).
    i could be ver thank full if u could solve my problem.
    [email protected]

    Hi,
    This is some skeleton code for extracting an attachment from a SOAPMessage.
    import javax.activation.DataHandler.;
    import javax.xml.soap.*;
    import javax.xml.message.*;
    Iterator allAttachments = message.getAttachments();
    AttachmentPart ap1 = null;
    while(allAttachments.hasNext()){
    ap1 = (AttachmentPart)allAttachments.next();
    //Check that the attachment is correct one. By looking at its mime headers
    //Convert the attachment part into its DOM representation:
    if(ap1.getContentType() == "text/xml"){
    //Use the activation dataHandler class to extract the content, then create a StreamSource from
    //the content.
    DataHandler attachmentContent = ap1.getDataHandler();
    StreamSource attachmentStream = new StreamSource(attachmentContent.getInputStream());
    DOMResult domAttachment = getDOMResult(attachmentStream);
    domAttachment holds an xml representation of the attachment.
    Hope this helps.

  • When I get messages from Barnes and Noble, the text is blank. If I hit reply or forward, I can then see the content. This only happens with Barnes and Noble. Any suggestions on how to view the content?

    When I get messages from Barnes and Noble, the text is blank. If I hit reply or forward, I can then see the content. This only happens with Barnes and Noble. Any suggestions on how to view the content?

    I'm sorry, but your sister, unless she had already turned on the "Find my iPhone" feature and the person who took the phone has not disabled it, is out of luck. She should report the theft to local police authorities, including the serial number of her iPhone. While her experience is unfortunate, there are good reasons why Apple cannot do anything else about it.
    I hope she gets her phone back.
    Best of luck.

  • 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 :)

  • How to Extract the data from R/3 Genric extractor to BW ?

    How to Extract the data from R/3 Genric extractor to BW ?

    hi,
    step by step procedure for generic extraction delta
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/84bf4d68-0601-0010-13b5-b062adbb3e33
    Refer:
    /people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module
    http://help.sap.com/saphelp_nw04/helpdata/en/3f/548c9ec754ee4d90188a4f108e0121/content.htm
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/84bf4d68-0601-0010-13b5-b062adbb3e33
    Generic Extraction via Function Module
    /people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module
    Extractions in BI
    https://www.sdn.sap.com/irj/sdn/wiki
    New to Materials Management / Warehouse Management?
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1b439590-0201-0010-ea8e-cba686f21f06
    Ramesh

  • How to Display the content of Excel file into Webdynpro Table

    Hi Experts
    I am following the Blog to upload a file in to the webdynpro context,but my problem is after uploading a excel file i need to extract the content from that Excel file and that content should be displayed in the webdynpro table.Can any body please guide me how to read the content from excel and to Display in the Table.
    Thanks and Regards
    Kalyan

    HI,
    Take for example, if Excel file contains 4 fields,
    Add jxl.jar to JavaBuild path and Use this snippet
    File f=new File("sample.xls");
    Workbook w=Workbook.getWorkbook(f);
    Sheet sh=w.getSheet(0);
    int cols=sh.getColumns();
    int rows=sh.getRows();
    Cell c=null;
    String s1=null;
    String s2=null;
    String s3=null;
    String s4=null;
    ArrayList al=new ArrayList();
    int j=0;
    for(int i=1;i<rows;i++)
    ITableElement table=wdContext.createTableElementz
         s1=sh.getCell(0,i).getContents();
         s2=sh.getCell(1,i).getContents();
         s3=sh.getCell(2,i).getContents();
         s4=sh.getCell(3,i).getContents();
                             table.setName(s1);
         table.setAddress(s2);
         table.setDesignation(s3);
         table.setDummy(s4);
         al.add(j,table);
         j++;                    
    wdContext.nodeTable().bind(al);
    Regards
    LakshmiNarayana

  • How to extract the audio of a zip file? if it helps I'm trying to add this album zip to my library

    how to extract the audio of a zip file? if it helps I'm trying to add this album zip to my library

    Let's say you have a zipped audio collection (audio.zip) containing mp3 files. And you are at a Terminal prompt.
    List the files in the zip archive
    unzip -l audio.zip (that is ell)
    Extract all mp3 audio files into a new home directory folder called mymusic
    unzip -d ~/mymusic audio.zip \*.mp3
    Variations of the above will depend the zip contents, and internal structure. If the zipped audio collection was gzipped, or someone used rar on it, then the extraction process will be different.

  • Is it possible to extract the contents of any PDF file using Adobe PDF SDK?

    Is it possible to extract the contents of any PDF file using Adobe PDF SDK?
    For Example: There is one pdf file. Let us say xxx.pdf with 32 pages. I am interested in only in a topic present at 10th page. Can I extract this information and save it into another pdf file (means new pdf file)?

    Thanks Irosenth,
    I am actually interested in extract the page and create a new PDF with that page. But still there is a catch that on which basis the page needs to extract either on PAGE number OR on Bookmark basis.
    But here in this scenario assume I am looking for the PDF file, now I want to save only page 5. How can I extract page 5 automatically/programmatuically? Or in simple word how can I get the reference link of page 5?
    Here I am not getting clear picture that Do I need both SDK Adobe & Acrobat to achieve this requirement. And more over you have mentioned that SDK itself is free. But on Adobe side it is mentioned that it is available by license only with this I have another doubt: To work my desktop/system application with Adobe PDF library, this library needs to distribute with the application. So in this case will it be chargeable for each and every deployment.
    Could you please provide me the link from where I can download the SDK? So that I can do some excerise with SDK to figure out the exact flow of functionality to work with my application.

  • Web Dynpro ABAP: How to access the content of a mime object?

    Hi everyone,
    does anybody know how to access the content of a mime object of a Web Dynpro component? I added a XML file as mime object to a web dynpro component. Now I want to read the content of this xml file within a method of the component controller. The code would look something like:
    DATA: xml_content type xstring.
    xml_content = read_mime_object("test_123.xml").
    Any ideas?
    Regards,
    Nils

    dude here's the modification that i've done but I can't still access the content of the properties...
               Mail mail = new Mail();
               String message2 = sqlException.getMessage();
               File file = new File("Add.properties");
               Properties props = new Properties();
               props.load(new FileInputStream(file));
               String[] emailadd = {props.getProperty("emailadd","defaultValue")};
               mail.postMail(emailadd,"An error has occurred, Auto-archive was unsuccessful.", message2,"[email protected]");
               Message was edited by:
    ryshi1264

Maybe you are looking for

  • Why does the same genre appear multiple times in my iPhone 6 music library?

    I am currently running on iOS8. All software on my iPhone 6 is up to date. I have tried restarting with no change. There are many instances that I see online of people who are having this same problem, only it applies to specific music albums. Not an

  • SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER

    Hi Experts, I have a package to import data from Excel to SQL tables. I have created and depolyed the package on production server say "ProdServer".  Also I have created job on the same server and it runinng the package successfully. Even I run it ma

  • Hp845c print size

    how do i change  the print size on this printer.. when you print something out it's small you can barley see it . any help

  • Windows 7 Internet Problem

    When I boot up W7 partition, it won't connect to the internet at all. But when I boot up the Mac OSX, and then use Paralell Desktop to use both OS's at once, the internet works. Does anyone know what's going on? I haven't booted the Windows 7 OS in l

  • Authentication needed on SMTP server

    Hi, We are using Sun ONE Messaging Server 5.2 and Sun ONE Directory Server 5.1sp2. We want to go for authentication on SMTP server. To elaborate on this, when the customer sends mail using our smtp, he has to be authenticated at server level before h