• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Mail with attached Image  RSS feed

 
shalni sundar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to combine three different images into one? And send the processed image through mail.

If any one know about the thing please help me.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "combine" - overlay with transparency? Put them next to one another horizontally or vertically? Something else?

Also, is the problem with the image processing, or with sending a mail with an attachment?
 
shalni sundar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem with image processing.,

i want to send some templates thru mail automatically., for that i am trying to do some changes like Text writing over an image and change font etc.,

So i am using awt.Image API. And I am sending the mail as HTML mail. I can able to send the static image.,
i can't do for that java Image.,

Thanks
 
Rakesh Jhamb
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use javax.mail utility to send images as an attachment in the mail
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the problem is not with the image processing, but with how to save an Image object to a file (since you said you can attach a static image file just fine); is that correct?

If so, you can convert an Image to a BufferedImage and then save the BufferedImage to disk.
 
shalni sundar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have wriiten some code ., that convert html code to Image "png" file.
I am not getting the full content in the image file what could be the problem.

I am stuck with this.

Code Snippets:
HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
HTMLDocument htmlDocument = (HTMLDocument) htmlEditorKit
.createDefaultDocument();
JEditorPane editor = new JEditorPane();
editor.setEditable(false);
editor.setEditorKit(htmlEditorKit);
editor.setText(templateString);

// Write to file
Dimension prefSize = editor.getPreferredSize();
BufferedImage img = new BufferedImage(prefSize.width, editor
.getPreferredSize().height, BufferedImage.TYPE_INT_ARGB);
Graphics graphics = img.getGraphics();
editor.setSize(prefSize);
editor.paint(graphics);
ImageIO.write(img, "png", file);

 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the image large enough for the full contents? You're sizing the image to the height of the editor pane - which will be too small if the content of the editor pane needs scrolling.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!