tags:

views:

48

answers:

3

Hi All :
I have a code which creates an image in application server and that image has been referred in mail html. After sending mail, image will be deleted in application server. When i open the mail , image is not getting display in the mail.

The reason i guess is , my code is deleting the image before it copied to mail server. I have checked by deleting the image manually.

First i opened the mail(this time image get copied to mail server) and then deleted the image in application server. When i open the mail 2nd time, image get display(because image is in mail server i guess)

Again i ran the code, this time before opening mail first time, i deleted the image in application server and opened the mail. Image is not displaying(because image not getting copied to mail server).

Please tell any solution to solve this problem. Do not tell that to add image as attachment, i should not do that as per my requirement.

A: 

If you can't attach the image then you have to ensure than whatever external img src is being referred to (e.g. <img src="http://foo.com/bar.jpg"/&gt;) remains accessible as long as people could reasonably view the message.

Matthew Flaschen
A: 

If the image is referred to in the mail as an external http resource, then it will be visible as long as it is available on the server.

You can, indeed, attach the image to avoid this problem, but those are the only to options I know.

streetpc
How do i attach the image in mail???
Tutorial:http://java.sun.com/developer/onlineTraining/JavaMail/contents.html#JavaMailAttachments
streetpc
And below on the same page is exactely what you want to do:http://java.sun.com/developer/onlineTraining/JavaMail/contents.html#IncludingImagesWithHTML
streetpc
A: 

You say that the image is "referred to" in your mail?

The img tag will contain a link (src) to you image. Your image must be at this location when the mail is viewed.

If you're deleting the image from this location then obviously it can't be displayed.

Glen
Yeah but when i delete the image after opened mail first time and it getting display in the mail when i open second time. It shouldn't display as per view rite?
If it's a link, then every time you open the mail it'll try to download it from the location specified in the src part of the img tag. So if you've deleted it then it won't display. (Unless it's cached on the client side, but when the cache is cleared then it'll stop displaying)
Glen