• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Sending Webpage thru Java Mail  RSS feed

 
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
 
Rancher
Posts: 42974
76
  • 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
 
Sheriff
Posts: 21745
102
Chrome Eclipse IDE Java Spring Ubuntu VI Editor 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.
 
Skool. Stay in. Smartness. Tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!