• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sending Webpage thru Java Mail

 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic