This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Content-id format of mail message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Content-id format of mail message" Watch "Content-id format of mail message" New topic

Content-id format of mail message

Siddhesh Deodhar
Ranch Hand

Joined: Mar 05, 2009
Posts: 117
Hi all

I have my mail reading application in jsp which display's an email message. I am trying to display a mail which is having images embedded in it.
However i am not able to see images contained inside mail. I can see images when i open the mail in thunderbird.

When i opened mail message in notepad i saw that content-id value of images referenced was not present withing angular braces.


<img src="cid:Logo.gif"..>

corresponding content was like follows

Content-Disposition: inline; filename=Logo.gif
Content-ID: Logo.gif

So here , if i replace line "Content-ID: Logo.gif" with "Content-ID: <Logo.gif>", I am able to view images.
As per RFC (, i found that content-id is enclosed in angle brackets (<>) but on wikipedia, I found that this is not mandatory.
Anyone knows what's the correct format of content id ?

Within my code while reading the message, if i go to change value header "Content-id" to "<logo.gif" using setHeader method, I get IllegalWriteException.
I guess its because i cant modify incoming mail . Please correct me if I am wrong.

Good, Better, Best, Don't take rest until, Good becomes Better, and Better becomes Best.
Sidd : (SCJP 6 [90%] )
Siddhesh Deodhar
Ranch Hand

Joined: Mar 05, 2009
Posts: 117
Resolved while parsing the mail. Added logic to extract data in different fashion.
I agree. Here's the link:
subject: Content-id format of mail message
Similar Threads
WS and tomcat
How to load an image from java program
Selecting row in jsp
How to set Multilanguage Subject in Javax.mail
Sending email in Arabic MIME issue