• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending Webpage thru Java Mail

 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
code.jpg
[Thumbnail for code.jpg]
Code
 
Rob Spoor
Sheriff
Pie
Posts: 20559
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic