Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Please Help:[JavaMail]How to make the embeded images display properly when to show a Multipart/related message?

Reply
Thread Tools

Please Help:[JavaMail]How to make the embeded images display properly when to show a Multipart/related message?

 
 
M.Liang Liu
Guest
Posts: n/a
 
      05-25-2007
Hi,all:
I am writing a web application to show mails received by JavaMail.
And I found that some content-type of the mail headers is:multipart/
related,which means there are some embeded images,vidios,etc.And I
checked the original tmp file to find the mail contains one part
labeled "text/html",including tokens as this:
++++++++++++++++++++++++++++++++++++++
<DIV><FONT face=Verdana><IMG alt="" hspace=0
src="cid:(E-Mail Removed)"
align=baseline border=0></DIV>
++++++++++++++++++++++++++++++++++++++
I found the id of one of the parts which looks like an attachment, is
"(E-Mail Removed)" and I assumed that it was the very image.
OK,the question is:
How to make the embeded images display properly when to show a HTML
message?

Any comments is greatly appreciated.
Pardon me for my poor English

 
Reply With Quote
 
 
 
 
M.Liang Liu
Guest
Posts: n/a
 
      05-28-2007
On May 25, 6:16 pm, "M.Liang Liu" <(E-Mail Removed)> wrote:
> Hi,all:
> I am writing a web application to show mails received by JavaMail.
> And I found that some content-type of the mail headers is:multipart/
> related,which means there are some embeded images,vidios,etc.And I
> checked the original tmp file to find the mail contains one part
> labeled "text/html",including tokens as this:
> ++++++++++++++++++++++++++++++++++++++
> <DIV><FONT face=Verdana><IMG alt="" hspace=0
> src="cid:(E-Mail Removed)"
> align=baseline border=0></DIV>
> ++++++++++++++++++++++++++++++++++++++
> I found the id of one of the parts which looks like an attachment, is
> "(E-Mail Removed)" and I assumed that it was the very image.
> OK,the question is:
> How to make the embeded images display properly when to show a HTML
> message?
>
> Any comments is greatly appreciated.
> Pardon me for my poor English


Multipart mp = (Multipart) part.getContent();
Part tmp = mp.getBodyPart(0);
String body = LmlMessage.getBody(tmp, userName);
int count = mp.getCount();
for (int k = 1; k < count; k++) {
Part att = mp.getBodyPart(k);
String attname = att.getFileName();
File attFile = new File(Constants.tomcat_AttHome_Key,
userName.concat(attname));
FileOutputStream fileoutput = new FileOutputStream(
attFile);

try {
InputStream is = att.getInputStream();
BufferedOutputStream outs = new BufferedOutputStream(
fileoutput);
byte b[] = new byte[att.getSize()];
is.read(b);
outs.write(b);
outs.close();
} catch (Exception e) {
logger
.error("Error occurred when to get the photos from server");
}
String Content_ID[] = att.getHeader("Content-ID");
if (Content_ID != null && Content_ID.length > 0) {
String cid_name = Content_ID[0].replaceAll("<", "")
.replaceAll(">", "");
body = body.replaceAll("cid:" + cid_name,
Constants.server_attHome_Key.concat("/")
.concat(userName.concat(attname)));
}
}
sb.append(body);
return sb.toString();

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      05-28-2007
On 25 May 2007 03:16:17 -0700, "M.Liang Liu" <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

>How to make the embeded images display properly when to show a HTML
>message?


I think what you have to do is translate the bastardised HTML used in
Emails into traditional HTML, then render that.

See http://mindprod.com/jgloss/htmlrendering.html
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PLEASE HELP--Button images refuse to show. Barrett Python 1 04-23-2010 03:09 AM
CD-ROM drive does not show in Win 98 Explorer; "working properly" in Device Manager L Mehl Computer Support 1 11-27-2006 09:12 PM
how do i show/hide a div within a table cell properly? Susanne West HTML 4 11-15-2006 04:38 PM
how to display word file embeded in access 2002 table in IE bigsea76 ASP .Net Web Controls 0 04-17-2004 09:36 AM
More American Graffiti: Properly Framed, Properly Scored? Scot Gardner DVD Video 0 09-02-2003 02:28 AM



Advertisments