How to fetch Header and Payload from a MimeMessage

Hi,
I have created a MimeMessage using an InputStream 'ins' like this
MimeMessage mimeMsg = new MimeMessage(Session.getInstance(new Properties(), null), ins);This MimeMessage now looks like as shown below:
Message-ID: <30289364.1195019945580.JavaMail.rishi@ap00475>Mime-Version: 1.0Content-Type: multipart/related;      boundary="ERCOT-XML-DATA";     Type="Application/X-ERCOT-MARKETS"--ERCOT-XML-DATAContent-Type: Application/XMLContent-Transfer-Encoding: 7bit<.....XML header....>--ERCOT-XML-DATAContent-Type: Application/XMLContent-Transfer-Encoding: 7bit<.....XML payload....>--ERCOT-XML-DATA--How can I get the above message to look like a proper MIME message (as shown below)? I tried using the method parse(), but it doesn't seem to do anything.
Message-ID: <13665843.1194849042656.JavaMail.rishi@ap00475>
Mime-Version: 1.0
Content-Type: multipart/related;
     boundary="ERCOT-XML-DATA";
     Type="Application/X-ERCOT-MARKETS"
--ERCOT-XML-DATA
Content-Type: Application/XML
Content-Transfer-Encoding: 7bit
<.....XML header....>
--ERCOT-XML-DATA
Content-Type: Application/XML
Content-Transfer-Encoding: 7bit
<.....XML payload....>
--ERCOT-XML-DATA--Also, how can I fetch the XML headers and the XML payload from this message? It would be great if you could tell me which methods in particular will be useful for this?
Thanks,
Rishi

Hi bshannon,
Here is my code. Here I am trying to create an inputstream from a mime message and vice versa. But while creating the Mime message back from the inputstream, it does not give the linebreaks. It looks like one single line of string. Also I am not sure how I can fetch the XML header and payload from this message.
ByteArrayOutputStream bos = new ByteArrayOutputStream();
          mimeEncodedMsg.writeTo(bos);
          byte[] ba = bos.toByteArray();
          ByteArrayInputStream bin = new ByteArrayInputStream(ba);
          BufferedReader inputReader = new BufferedReader(new InputStreamReader(bin));
          StringBuffer serverResponse = new StringBuffer();
                         while ( inputReader.ready() )
                              serverResponse.append( inputReader.readLine() );
                         inputReader.close();
// -----------------MIME conversion to InputStream done----------------------     
          BufferedReader serverReader = new BufferedReader( new StringReader (serverResponse.toString()));
          StringBuffer servResp = new StringBuffer();
               servResp.append( serverReader.readLine());
          serverReader.close();
          byte[] ba1 = servResp.toString().getBytes();
          ByteArrayInputStream bin1 = new ByteArrayInputStream(ba1);
          MimeMessage mimeDecodeMsg = new MimeMessage(Session.getInstance(new Properties(), null), bin1);
          mimeDecodeMsg.writeTo(new FileOutputStream("C:\\MimeTest2.txt"));Any idea why this is happening?
Thanks,
Rishi

Similar Messages

  • How to remove Header and Footer from Flat File

    Hi,
    In a scenario , we are going to recieve a flat file which will contains header , footer and data. We have to have to load data in Oracle tables and remove header and footer.
    once the data load is complete , we have to delete flat file from source directory.
    Please help me in solving this issue.
    Thanks,
    Kamlesh

    You have a header parameter in the file datastore. You can provide any number to skip rows from top of the file. For footer you can create a filter in staging area.
    Filter coould be something like this.
    where source_alias.source_column not like '%FOOTER_OR_ANY_VALUE_AS_PER_YOUR_REQ'

  • How to remove header and footer from a "blank" page in Pages?

    Hi,
    In the top and the bottom there seems to be a header and footer, it noticeable when i do "mouse over". But when i right click i don't get the option to delete it. I cannot move it. I cannot move any other text or colums above it.
    ??? Help

    +Inspector > Document (1st tab) > Document > Uncheck Header and Footer+
    The Pages09_UserGuide.pdf is available for download under the Help menu and is a good read.

  • How delimited by header and footer from Source file in BPEL 11g

    Hi Friends,
    I have source data below like This..
    SOFTWARE COMPONENTS:
    BPEL 11G,
    J DEVELOPER(11.1.1.3)
    FILE READ ADAPTER
    WEB LOGIC EM SERVER(10.3.3.0)
    1|10005|857896|BR |0000 |6544|kantro|54635
    1|10265|69875|.36544|2456112|00000|000000|00000|SE|5456|466554|789745|54.325|KVM|56476.32
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|55566|4454544|45669
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|55566|4454544|45664
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|55776|4454544|45660
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|55566|4454544|85668
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|55566|4454544|45666
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|85876|4454544|45666
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|55566|4454544|69848
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|69566|4454544|45666
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|78966|4454544|85669
    1|10255|km|5653|RJ |00000|5557544|13-08-1998
    But i need to Delimited and insert the data into table ..Here Header data insert into saperate table and
    middlle of the data insert into main table and footer data insert in another table it all happen one attempt by using file read Adapter(11.1.1.1.3)

    You have a header parameter in the file datastore. You can provide any number to skip rows from top of the file. For footer you can create a filter in staging area.
    Filter coould be something like this.
    where source_alias.source_column not like '%FOOTER_OR_ANY_VALUE_AS_PER_YOUR_REQ'

  • How to fetch folders and subfolders from sharepoint document library

     I have document library with name . Under "Documents" there are some folders.Under some folders there are some subfolders.
    I need to fetch the folders in to dropdown list. IF I select some folder in dropdownlist,I need to fetch subfolders of that folder to some other dropdownlist.
    How to acheive this

    The below function get the folder name and id of subfolder where items stored folder = item.folder.  Initially it will be null.
    static
    string GetParentFolder(SPListItem itemToFind,
    SPFolder folder) 
    SPQuery query =
    new SPQuery();
    query.Query = "<Where><Eq><FieldRef Name=\"ID\"/><Value Type=\"Integer\">"+ itemToFind.ID +"</Value></Eq></Where>";
    query.Folder = folder;
    query.ViewAttributes = "Scope=\"Recursive\"";
    SPListItemCollection items = itemToFind.ParentList.GetItems(query);
    int intpartentFolderID=0 ;
    if (items.Count > 0)
    foreach (SPListItem item
    in items)
    SPFile f = item.Web.GetFile(item.Url);
    string test11 = f.ParentFolder.Name;
    intpartentFolderID = f.ParentFolder.Item.ID;
    return (intpartentFolderID.ToString());
             return (intpartentFolderID.ToString());    

  • HT1349 how  do you remove the header and footer from a document

    how  do you remove the header and footer from a document

    It depends upon the app you are using.

  • How to disable auto header and footer from firefox desktop Application

    I build a Firefox desktop application for my company. i need to print some page from that application using JS window.print(). It Works Perfectly in my application. But the problem is when it printing my document it prints a header and a footer automatically. I Want to remove this. I can remove this on Firefox browser , but i cant remove this on my application. Please Somebody Help Me.
    here is my application link: https://marketplace.firefox.com/app/hmspro
    User Login : admin / Password: 123
    if you want to get into printing page navigate invoice > paid invoice > print button.
    I also tryed from about:config and disable all default header footer. but it wont worked.

    Hi saaiful,
    Thank you for posting your question. window. will print header and footer.
    Here are some solutions I found after researching your issue:
    *[http://forums.mozillazine.org/viewtopic.php?f=12&t=216810]
    *[http://stackoverflow.com/questions/8228088/remove-header-and-footer-from-window-print]
    *[http://www.dreamincode.net/forums/topic/22598-using-windowprint-without-printing-header-and-footer/]
    *take a screenshot and create a page that is printable [http://www.webdeveloper.com/forum/showthread.php?210947-Using-window-print-without-printing-header-and-footer]
    *Target to another window then print: [http://www.liferay.com/community/forums/-/message_boards/view_message/3401817]
    Hope this helps.

  • How to print header and footer in SET_TABLE_FOR_FIRST_DISPLAY

    Hello Experts,
             How to print header and footer while using the method SET_TABLE_FOR_FIRST_DISPLAY, any tips from the experts will be appreciated.
    Regards,
    Babu

    Hi,
    there are four events for printing: print_end_of_list, print_top_of_list, print_end_of_page and print_top_of_page. More information about implementing these events is in this bible for ALV:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
    Cheers

  • How to fetch Quartile and Comp Ratio columns

    Hello all
    How to fetch Quartile and Comp Ratio columns which are present in Enter and maintain -> Assignment screen -> Salary screen.Are they direct columns from any table or calculation columns.
    Someone please suggest me how to fetch those columns
    Thanks in advance

    Can anyone help me in writing a procedure/dynamic SQL to fetch the column where the junk values appears and its value. Eg: If emp table contains ID and Name columns, and ID column contains junk values, the result should be the Id column and the junk value/s. It should be dynamic because next time if the other column contains junk values(like $,%...), the query should display the other column too..1. define "junk" values.
    2. usually it does not matter what values are in ID, because it is used internally by application, to maintain uniqueness or relations, not having any semantical meaning. End users usually should not see IDs, such IDs are generated automatically. There is no need to cleanse them from "junk" values.
    3. If you made a typo, and you are looking for "junk" values in Name column, it is a different story. You can use TRANSLATE to search such values, as already advised, translating all "junk" characters to one "junk" character and searching for the latter.
    select id, name from T where translate(name,'?@#$%^<>','~~~~~~~~~') like '%~%';
    Edited by: Mark Malakanov (user11181920) on Jan 4, 2013 11:40 AM

  • How to change header and footer in login page in oracle apps r12

    Hi all,
    how to change header and footer in login page in oracle apps r12 and login button background color, please help me
    thanks
    saran

    how to change header and footer in login page in oracle apps r12 and login button background color, please help meTips For Personalizing The E-Business Suite R12 Login Page (MainLoginPG) [ID 741459.1]
    How to Personalize Login page in R12? [ID 579917.1]
    R12 Login Page: How to Personalize the Logo ? [ID 849752.1]
    Thanks,
    Hussein

  • How to place header and footer  in OO-ALV program using class

    How to place header and footer  in OO-ALV program using class tell me wat r the class we shold use and their attributes as well

    Hi Venkatesh,
    Take a look at this how to [ABAP Objects - ALV Model - Using Header and Footer|https://wiki.sdn.sap.com/wiki/x/xdw]
    it's explaining how to define the classes and use it for display an ALV with Header and Footer.
    Regards,
    Marcelo Ramos

  • How do I copy and paste from one page or file to another page or file - on the same screen?

    How do I copy and paste from one page or file to another - on the same screen?

      Open both of your images in the Editor. Click on the image you want to copy and press Ctrtl+A (select all) followed by Ctrl+C (copy) then click the tab for your other image and press Ctrl+V (paste)
    Alternatively click on your background image then simply drag the second image from the photo/project bin and drop it into the main editor workspace on top of the background image. Use the move tool to position and the corner handles of the bounding box to scale.

  • Need instructions on how to download photos and videos from my Samsung cell to my iPhoto

    Need instruction for how to import photos and videos from my Samsung cell phone to iPhoto.  Thx

    Copy the files to the Mac and then drag them to the iPhoto window, or use the File -> Add to Library command
    As for how to connect the phone and the Mac, for that you'll need to read the manual for the phone or seek support from a Samsung or Android (that's the operating system) site.

  • On iTunes 11.0, how do I delete and App from iTunes?  I tried selecting the App to be deleted and pressing Delete, but that did not work.

    On iTunes 11.0, how do I delete and App from iTunes?  I tried selecting the App to be deleted and pressing Delete, but that did not work.
    MoragaTom

    I have the same problem on my iPhone - an app I want to delete but can't. The app in question doesn't show up on the list of apps i iTunes and doesn't show an 'X' when it starts to wiggle. All the other apps do, but not this one. It's definitely an app. How do I get rid of it, please?

  • How to fetch only WebI reports from the repository

    How to fetch only WebI reports from the repository, where in we have Deski reports also in the repository.. any macro??

    here is the query to fetch only webi reports:
    Open Administration Launchpad (.Net / Java) from:
    Start >> All Programs >> BusinessObjects XI Release 2 >> BusinessObjects Enterprise >
    Click on the 'Query Builder' under 'Administration Tools' on the left pane.
    Logon to Query Builder using Enterprise Administrator credentials.
    Run the following query for Web Intelligence Reports:
    SELECT SI_ID, SI_NAME, SI_OWNER FROM CI_INFOOBJECTS WHERE SI_KIND='WEBI'
    Thanks,
    Srikanth.

Maybe you are looking for