Extracting content from MimeMessage

I am being passed a MimeMessage Object which would contain some text. Now the problem is that the content type of the MimeMessage comes out to be
[bold]
multipart/mixed; boundary="----=_Part_1_2168521.1026163248946"
[bold]
In such a case how r u supposed to extract the content from the Mime message. In case I try the getContent method and cast the result to String
System.out.println("ModifyMsg 307 " + (String) mimeMsg.getContent());it returns a
[bold]
java.lang.ClassCastException:
[bold]
Totally lost. Any help would be greatly appreciated.

It depends in the structure of your MimeMessage. I suggest you to check mimeMsg.getContent().getClass().getName(). It is a big chance that you have MimeMultipart object in there, so you should use getPart() on it, and so on and so forth recursively...

Similar Messages

  • Code Challange - Code for extracting content from a file in KM

    Hi,
      I want to extract content from a file which is in KM Repository using the Webdynpro View.  I wrote the following code for the extraction. But it is throwing some exception.
    Code Written:
    <b>  
      URLConnection conn = null;
          DataInputStream data = null;
          String line;
          StringBuffer buf = new StringBuffer();
         wdContext.currentContextElement().setTextdisp("Hello");
         try {
          URL theURL = new URL("http://ctssap1:50000/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/News/New%20text.txt");     
            conn = theURL.openConnection();
           // conn.connect();
            wdContext.currentContextElement().setTextdisp("Inside Try");      
            data = new DataInputStream(new BufferedInputStream(
                               conn.getInputStream()));
            while ((line = data.readLine()) != null) {
               buf.append(line + "\n");
            data.close();
            String buffer = new String(buf);
            wdContext.currentContextElement().setTextdisp(buffer);
          catch (IOException e) {
              wdContext.currentContextElement().setTextdisp("IO Error:" + e.getMessage());
          }</b>
    Exception Got:
    <b>IO Error:Server returned HTTP response code: 401 for URL: http://ctssap1:50000/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/News/New%20text.txt</b>
    Can anyone help me out in this process... or please suggest some other way to extract the content.
    Thanks in Advance.
    Regards,
    Srinivas.

    Hi Srinivas,
    VaPath will have the path of ur document.
    Check this modified code snippet which will answer ur  questions and solve ur problem.
    IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
    IUser sapUser = wdClientUser. getSAPUser();
    com.sapportals.portal.security.usermanagement.IUser ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);
    IResourceContext context = new ResourceContext(ep5User);
    /Specify the path of ur document here./
    RID pathRID = RID.getRID("/documents/file2");
    IResource resource = ResourceFactory.getInstance()
    .getResource(context);
    InputStream in = resource.getContent().getInputStream();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    byte[] buffer = new byte[4096];
    int bytesread = 0;
    while ((bytesread = in.read(buffer)) != -1) {
    out.write(buffer, 0, bytesread);
    String myData = out.toString();
    /*myFile will containS the content of the document./
    wdComponentAPI.getMessageManager().reportSuccess(myData);
    Hope this solves ur problem.
    Regards,
    Sowjanya.

  • Accessing/Extracting content from a DVD

    I have several DVDs that contain old family films from which the original media has been damaged or destroyed. I would like to be able to import these home movies into iMovie for editing. I can create a disc image on my desktop from the DVDs, but do not know how to import the content into iMovie from there. Any advice will be greatly appreciated. Thank you, Scott

    MPEG Streamclip will work, but you will need to purchase the $20 Apple Quicktime MPEG-2 component to make it work with DVD content. http://store.apple.com/us/product/D2187Z/A?fnode=NDQ4OTY4OA&mco=MTM3NDgwNTI

  • Extracting contents from Content Db to a file system

    Hi,
    What would be the best approach to extract the contents in Content Db to a file system and the metadata associated with them to a temporary database table
    so that we can use them to migrate documents to another content management system ?
    Thanks
    Edited by: user10343552 on Oct 9, 2008 10:12 PM

    Restore the database to the SQL Server that the test farm is using. Use Mount-SPContentDatabase on the test SharePoint server (farm) to mount the content database to the test Web Application.
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • Applescript - extracting content from Outlook help!

    Hi,
    I'm a forum newbie (ever) and a complete novice to apple script. I'm a graphic designer with some html knowlege - but this is all new.
    What I want to do:
    I manage a site that gets people to subscribe to a newsletter. When someone does I get an email like this:
    Here are the member details:
    Name:
    xxxxx xxxxxx
    Email:
    xxxxxxxxxx
    What I need to do is run a scipt taht will open each email (each has the same subject line and email address) - export to two diferent cells in excel the name and then email, and then delete thta particular email.
    Is this possible or am I asking my mac to simply do too much!
    I've recently crossed over from PC - so hoping my mac will pleasantly suprise me!
    thanks

    It depends in the structure of your MimeMessage. I suggest you to check mimeMsg.getContent().getClass().getName(). It is a big chance that you have MimeMultipart object in there, so you should use getPart() on it, and so on and so forth recursively...

  • How to extract content from a html-document

    Hi!
    I need to display the content of a news-feed
    like: http://news.bbc.co.uk/go/rss/-/1/hi/sci/tech/7662565.stm
    I'd like to display this in a JEditorPane with only the relevant content without the banner, menu and so on.
    Any idea on how I can do this?
    Cheers

    In this particular case, you don't want to parse the HTML but the RSS feed used to build this this page. The feed for this page is [http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/sci/tech/rss.xml]
    RSS feeds are XML based so it's easy to parse them. You can do it by hand or use a specialized library. One of the well-known library is ROME ( [http://wiki.java.net/bin/view/Javawsxml/Rome] ).
    Example : [Parse a RSS XML file|http://www.rgagnon.com/javadetails/java-0557.html]
    Bye.

  • Extract content from sparsebundle files

    Is it possible to open or "view inside" a sparsebundle file - and extract som files?
    I have a time machine backup that wont work in lion so I just want to extract some files

    Yes, files within sparsebundles are accessible.
    You can try these software utilities...BackupLoupe or Back-in-Time.

  • Resolved: Extracting Content from Project

    I'm using JDeveloper 10.1.3.1.0 to build a VCS extension
    I have code which uses a PathsConfiguration object (and its associated ContentSet object) to determine what content is contained within my project / jpr. This is working well, but if I add a deployment profile to my project, since this is classed as a resource, it seemingly doesn't get listed within the ContentSet object.
    I know I can get the project's content via a PathsConfiguration object, and the project's libraries via a JProjectLibraries object, but I don't know how to get at the project's resources. Can anybody help me?
    If it would help, I can post my .jpr file.
    Message was edited by:
    Bubble369

    PathsConfiguration and JProjectLibraries are very specific to a Java-based IDE, whereas ResourcePaths could be applicable to other products based on the IDE platform. This is why the former two are in oracle.jdeveloper.model, while the latter is in oracle.ide.model.
    Thanks,
    Brian

  • Could not get exact contents from pdf using adobe acrobat professional

    Hi,
    I am using acrobat professional to extract contents from a pdf into HTML. During extraction of pdf into HTML some contents are getting rendered as images. But with pdf to xml extraction i can get the exact contents. But i need HTML file from pdf. Any suggestions. Thanks in advance.

    You might want to see if you can select the background with the object touchup tool. If so, can you then just delete the selected object. May take a while to go through the document, but if it solves the problem you are ahead. You may be able to select it with JavaScript and repeat the process. My point of using the object touchup tool is that it may not be a background set by Acrobat, but something that is simply labeled as an image from the Acrobat viewpoint.

  • Accessing KM content from within a web application

    We are trying to migrate an application from a BEA webServer onto the webAS. The application relies heavily on the BEA content management system (CMS), this is to be replaced by the KM. We cannot rebuild the application using iViews etc as we have to retain the current look and feel, and hence we will have to call the KM content from the jsp code within the application. Does anyone know if this is possible and can give us an idea of what API's we call...(if the API’s exist and if this is the correct approach).
    Many thanks

    ]> call the KM content from the jsp code
    ]That sounds not very well designed...
    BEA have a content tag library for extracting content from the CMS within a JSP page.  I think this is what James may be referring to.
    Does the KM have equivalent taglibs?  If so, can these be configured to access the KM running on a different J2EE instance (specifically one running on another machine).
    Going to browse the API docs anyway, but if you have a short answer to this, please post.
    Gary

  • Extracting contents of a PPT file

    Hi all,
    Is it possible to extract contents from a PPT using java ? Like getting the text and image information slide by slide..... Please help me.
    Thanks in Advance ,
    Ravi

    I'm sure there's some kind of API, but I've found that Google is the best place to ask general questions.

  • Change in capital to Lower while extracting contents

    While extracting contents from PDF Capital Letters are changed to small and a tab space is created between some words . Can you please suggest me how this can be solved. Thank  you in advance.

    That file isn't faulty. Just was created incorectly.
    Capital text was created by using wrong function in InDesign.
    Here you can find more info about it
    http://blog.idrsolutions.com/2012/04/understanding-the-pdf-file-format-actualtext/
    Regards
    Bartek

  • How to extract original file contents from content server

    Hi,
    1)How can we extract original file contents from the content server (which in our case is SAP database itself)...
    2)What exactly is PHIO_ID and LOIO_ID?
    Thanks and regards,
    Santhosh Kumar U.P

    Hi,
    concerning your first question - please decribe, what you are trying to do.
    Question 2:
    LOIO_ID is the ID of the Logical Information Object. A LOIO is not a real document, but kind of a virtual document, a containerfor all "real" versions of a document. A PHIO (physical info object) is a real document.
    you can read more at http://sercie.sap.com/Kpro
    Kind regards,
    Carl

  • Extracting documents from Sharepoint 2013 Content Database

    harepoint 2013 stores documents in the WSS_Content database in a table called DocStreams.
    Up until Sharepoint 2010, files where stored in a single row in a VarBinary column. Since Sharepoint 2013, files are stored in multiple rows using Shredded Blob storage.
    Does anyone know how I can piece together the files from the shredded storage in c#?
    I have found many exampled online to extract files from SharePoint 2010 and earlier but they only support a files content being stored in 1 row.

    Just wondering, can't you attach the database in a new site and access documents? As I know, in SharePoint 2013 they have changed architecture to manage versioning. In pre-SharePoint 2013 every individual versions was a duplicate copy of the  document
    - which would increase db size and would make it difficult to move documents in the cloud. So in SharePoint 2013 they use delta concept - where if you edit a document which creates a new version, the version is the delta (changes) to previous version.
    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com

  • How to extract a folder (and its contents) from inside a zip file?

    There is a zip file which contains a folder inside it. The folder itself contains a few files. I would need to know how to extract the folder (with its contents) from inside a zip file.
    I have found a few unzipping code samples which show how to handle a folder inside a zip file. An example is shown below:
    public static void extract(String workingDirectory, byte[] zipFile)
    throws Exception {
    ByteArrayInputStream byteStream = new ByteArrayInputStream(zipFile);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ZipInputStream zipStream = new ZipInputStream(byteStream);
    ZipEntry zipEntry = null;
    String nameZipEntry = null;
    byte[] contentZiphttp://forum.java.sun.com/post!default.jspa?forumID=31#
    Click for code tagsEntry = null;
    boolean isDirectory = false;
    int indexFileSeparator = -1;
    String directory = null;
    String fileName =  null;
    while ( (zipEntry = zipStream.getNextEntry()) != null )
                nameZipEntry = workingDirectory + File.separator + zipEntry.getName();
                isDirectory = zipEntry.isDirectory();
                if (isDirectory) {
    File file = new File(nameZipEntry);
    file.mkdirs();
                else
                    // read zipEntry
                    byte[] buf = new byte[1024];
                    int c = 0;
                    while ( (c = zipStream.read(buf)) != -1)
                        out.write(buf, 0, c);
                    indexFileSeparator = nameZipEntry.lastIndexOf(File.separator);
                    directory = nameZipEntry.substring(0, indexFileSeparator);
                    fileName =  nameZipEntry.substring(indexFileSeparator+1,nameZipEntry.length());
                    FileSystemTools.createFile(directory, fileName, out);
                    out.reset();
                    zipStream.closeEntry();
            zipStream.close();
            byteStream.close();
    }The code sample which deals with the part where the zipEntry is a directory creates a directory with the same path and name. (highlighted in bold)
    Another similar variation is:
    File file = new File(dirDestiny.getAbsolutePath() + File.separator + zipEntry.getName() );
    if(zipEntry.isDirectory())
          file.mkdirs();When the code creates a directory for the folder, does it unzip the contents inside the folder as well?
    If not, how do I extract the files inside the folder?

    Have you already tried to see if the sample code you downloaded works or not? Maybe if you try out the code yourself you can see if it extracts files from a directory within a zip file?
    I like to use pkzip. It is a command line compression/uncompression tool that can be used from a batch file. If you assignment involves unzipping large amount of zip files on a regular basis, I recommend taking a look at pkzip.

Maybe you are looking for

  • Many to Many - display query result?

    Greetings In a help desk app, the manager can assingn more than one technician to a project. Whe he or she assigns a project, the tech ID & project ID are inserted in a junction table. This works fine. The description, assigned date & due date field

  • Best way to edit PHP files in FB4?

    I'm trying out FB4 and would like to be able to use a PHP editor within the FB application. At the moment the PHP files it generates open up in Dreamweaver, which is fine but it would be better to have one tool than two. I tried to install the Eclips

  • Program not working properly.

    Hello all, The code below display a button and 3 option (radio) buttons. The program must uncheck the selected radio button when the button is clicked. Actually nothing happens in this code, that is the selected radio button has no change. Can anyone

  • Can't download form iTunes store onto my Mac

    I have four items waiting to download in iTunes Store, however, I can't seam to get the items to download onto my on iTunes on my mac.  I have logged into itunes store, and have a message telling me that I have items awaiting download.  When I hit th

  • Callback function as soon as animation complete

    Hi all, My question is very straight forward: I would like to fire up a function as soon as a symbol has finished playing, and i would like to write the code in the stage event. Ive created a very simple exmple for the matter: I have two symbols each