Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Image is not added when converting eml into htm

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Image is not added when converting eml into htm

    Hi 1 & All,

    I have a problem while converting eml into htm. i.e. the image in the eml is not added to htm.
    Iam using BufferedInputStream and BufferedOutputStream to read the eml body part and write into an htm.

    eml body has text/html part which i wanted to create as separate html file.
    The images are added in this text/html part by specifying the content-id of that image
    i.e. ,
    <TD width="233px"><IMG align="absbottom" src="cid:a" width="233" height="38"></td>
    <TD width="100%"><IMG align="absbottom" src="cid:b" width="100%" height="38"></td>

    This content-ids are defined at the bottom of the eml file.

    Now, the problem is the htm file is created without adding these images and the images are created as separate pages.

    Can any one Please tell me where actually iam going wrong.

    Thanks & Regards,
    Vjay


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default Re: Image is not added when converting eml into htm

    Is this a Java programming problem or an HTML problem?
    If you know what the correct HTML is that should be written, are you having a problem making your java program write it? If so please show the code where the problem and show what it writes that is wrong.
    If you don't know what HTML should be written, try an HTML forum.

  3. #3
    Junior Member
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Image is not added when converting eml into htm

    Quote Originally Posted by Norm View Post
    Is this a Java programming problem or an HTML problem?
    If you know what the correct HTML is that should be written, are you having a problem making your java program write it? If so please show the code where the problem and show what it writes that is wrong.
    If you don't know what HTML should be written, try an HTML forum.

    --------------------------------------------------------------------------------------------

    Hi Norm, Thanks for your reply.

    Ya, I think its java problem, As i told iam using BufferedInputStream and BufferedOutputStream to write the htm file,

    i.e.,

    File partFile = new File(desFolder.getPath() + fSep + "message.htm");
    BufferedOutputStream bos =null;
    BufferedInputStream bis =null;
    try
    {
    System.out.println("srcPart : "+srcPart.getContent().toString()); // to get the html content
    System.out.println("srcPart.getInputStream() : "+srcPart.getInputStream().toString());
    bos = new BufferedOutputStream(new FileOutputStream(partFile));
    //initialize a buffered input stream for body part
    bis = new BufferedInputStream(srcPart.getInputStream());
    //read attachment contents into file
    int dummy = -1;
    while ((dummy = bis.read()) != -1)
    {
    bos.write(dummy);
    }
    done =true;
    }
    catch(IOException ex)
    {
    ex.printStackTrace();
    VWLogger.error("Exception Encountered!",ex);
    done = false;
    }

    The problem here is the eml file contains the htm part which is having
    <IMG align="absbottom" src="cid:a" width="233" height="38">

    The src="cid:a" i.e. the image content-id is defined at the bottom of the eml,

    i.e.,
    ----_16sofl2.1703ip2.1pf.BODYHTMLTEXT
    Content-Type: image/gif;name="gwava5.gif"
    Content-Transfer-Encoding: base64
    Content-ID: <a>
    Content-Disposition: inline;filename="gwava5.gif"

    R0lGODlh6QAmANUAAP////L69Of37+X26tjx38vs1cvs1L7nyr3nxrHjwLHjvqXetZjaq5SU
    lIvVoX/QlnvWlHt7e3LMjGXHgVjDc1jCd0u9bEq9a0qtYz65YjG1UjG0V zFrOSmtSimUSila
    OSEhISEYIQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAACwAAAAA6QAmAEAG
    /0CQcEgsGo/IZJKjaTqf0Kh0Sq1ar9isdsvVer5gT6cJCoU45VDazBaa08w0y NPksO9397vj
    YX+uEAIAg4SDAggXURCDEFYXAI1Vj5BSiwhSCIOJVYuUUQgCm1 ob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FfhDwLZcabFOZhnadr3BIMdEox9eSMTDftS1cfNNjz1E MNGDSccAZpEi5By5Ov02CH
    rdUtJIoRRdadHc2UHihZDOOAX4st99xefNaKBhhopLdZclwtzJ 5Ka5Ciip7GTffhiFdntytZ
    NHV1p+5KRQdpJpVFlR5LK1IeApyrPAV5K58WOgbk/Wtj6Y6Md3rLwJFiwQSww05BF2R7oP/3
    7XsHU29/Ld4BzC5GzvSW5W+A+jde5h0iJecDz0dtrAQ7ZCO4T/zacPTV5ixFOQQQEPsEs2Om
    KboddMq1SmybRC912P08WhRj2OOWSkuHl7P9XCZaPSGswxroIK e60r8uAiVxaQ8KpJgAACRw
    LJ1xIG+4i6BGvHaGwTElY3QJiBCGYZ1a9KMDGjKcBjrBusR4i4 BQAqDBXkWtRYSCWtTbn/6+
    dKhHLQAAAVgAAwoAAAVkAS7km0UbbBFC4v2BR1foAJ6oQ5fvpH CGXEBNmBxjvVthLxkd8B97
    aLZCDaCmA4LBgjnMkYEzkYIKrZCgGjWirrmIDDRms08uOhTDYw D/ygnXuhXCZGgYcLykiiM0
    GAxlpSjsbW8DBEiAOSqwQExF4VxBhEffqBIitJiKEyjL5CES8q swWvGJUxIEr5zgKxQGco9W
    BEwNn4fADVggAAAgAA8DcClHQqEVGMilLnfJy172knClmcOB8F Sy/THMhOQZTx5X1SpUFhA3
    UmSPAJJJniwx85SqBCA1xwNABI0vksy52h+yQyee8EMMYikUIb HwGm0goovJcGFrDKFJlLEm
    Cs/QYr/qaU8o5gSXvgyoQHUJnYp1EHN1YEIV+EDM5tSjJktTzQFJiJdCs K4TK6xjuBxWrW5O
    MWeA/CfEJkZSMGAsOs+x0O+EubshCS4eyfggWmlSlLkoGUY101SPIdz j0Vg5Ezw97Ze+OCqt
    hzWgc0hNqlKXmlTeOQdIFXvXG5yAi8yR6Ed4yNwyxHWKTWYhE6 HzYvQEqFOOgjU3RLVLWK+w
    M6pBSBh0OSmc2CUkDg4RQEJ7jp64sFb6rBUiB7rAAT+0iqi5lW eOw9qFKEeVLzRHsZbTauIm
    65GeOOiwiK0H+mDkFqSh7xb2QolUbELZ0h5jH1GTGmbdarfWuv a1sI2tbGdL29ra9ra4za1u
    d3vbBuFntasNAgA7



    Now my understanding is the BufferedStreams are not identifying this cid and they are not inserting the images into htm file(rather images are considered separately and separate gif images are generated).

    Can you please let me know the solution for this.

    Thanks and Regards,
    Vjay

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default Re: Image is not added when converting eml into htm

    the BufferedStreams are not identifying this cid
    I'm not sure what you are saying here. Do you think the BufferedStream is supposed to look at what you write ( the cid) and change it to something else?
    Won't that be the program's responsibliity, to scan through the input file byte by byte, find the cid string and replace it with something else?

Similar Threads

  1. converting int to char
    By surfbumb in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 18th, 2011, 11:59 PM
  2. Replies: 2
    Last Post: February 14th, 2011, 04:36 PM
  3. Urgent help required - converting image to array
    By Paulious in forum Algorithms & Recursion
    Replies: 0
    Last Post: September 1st, 2010, 06:24 AM
  4. Pixel Alteration in an image/image rotation
    By bguy in forum Java Theory & Questions
    Replies: 3
    Last Post: November 1st, 2009, 09:50 AM
  5. Replies: 4
    Last Post: May 1st, 2009, 03:32 PM