aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Sending Webpage thru Java Mail Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Sending Webpage thru Java Mail" Watch "Sending Webpage thru Java Mail" New topic
Author

Sending Webpage thru Java Mail

Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
Dear Ranchers

I have been assigned to make a small program for "Email Notification System" with the images and texts are coming from mysql database. This is used for sales promotion and stuffs like that. Some times attachments also has to be there... I have prepared a code snippet and below is the information. But when i run the code without any images in the background, the email is working so perfectly. The moment, when i put the images code (html part), the email recieved is with blank pages. Kindly let me know how best i can sort out the below issue with your enriched knowledge.



Thanks/Regards

Aravind Prasad
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41509
    
  53
The moment, when i put the images code (html part), the email recieved is with blank pages.

As far as I can tell, the HTML *is* blank, since it contains no content. Which part of the HTML do you think should produce something non-blank?


Ping & DNS - my free Android networking tools app
Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
Sorry the code was not coming out well. Here it is, only the html part i am putting now.

messageBodyPart1.setContent( "<html><body bgcolor=#FFFFFF leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>
</body></html>", "text/html; charset=utf-8" );

Regards / Aravind
Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
It is not actually sending the html tag. May be a limitation in the webpage.

I am sending the screen shot of the same.

Regards / Aravind



[Thumbnail for code.jpg]

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

The images are relative to the HTML document, but inside an email client, this stops working.

There are two ways of including images in HTML emails:
1) Embed them. I'd suggest using Apache Commons Email for doing this. However, I think this won't work with background images.
2) Use absolute URLs to some web server. However, most clients block these images by default. You can't work around this, it's a client setting.

So I'm afraid what you want isn't going to work the way you want. You should consider reworking the HTML to use IMG tags instead of background URLs, and then embedding the images.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending Webpage thru Java Mail