File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Image to String to Image in a email

 
Gaurav Kr. Arora
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The query seems complicated to me because of some constraints.
Constraints:
Have to use String message which should contain image. Not aware how can I convert a gif/jpeg/bmp/png image to java string object.
This string message object will be passed to one of my framework methods send(String type, String subject, String message) to send an email. In my email I want that image to come properly and shown to the user. there is no option to pass the image. It needs to be passed as String message.
Internally the send method of the framework will create MimeMessage etc. and send email.
Type of the email will be text/html.

What could be the best possible solution to send a image as a message body when the method send takes only String argument?

Thanks
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume that behind the scenes you are using the JavaMail API to send the email. In which case you need to add a method to your framework that allows you to send a MimeMultipart attachment. There are examples of how to do this in the JavaMail distribution.

Note - JavaMail Base64 encodes binary data which means it only contains ASCII characters.
 
Gaurav Kr. Arora
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Sabre wrote:I assume that behind the scenes you are using the JavaMail API to send the email. In which case you need to add a method to your framework that allows you to send a MimeMultipart attachment. There are examples of how to do this in the JavaMail distribution.

Note - JavaMail Base64 encodes binary data which means it only contains ASCII characters.


I don't want to send the image as an attachment. Instead I want to send it as a message body. How can we achieve this?
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gaurav Kr. Arora wrote:

I don't want to send the image as an attachment. Instead I want to send it as a message body. How can we achieve this?


It is easy enough to Base64 encode the image and add that as the body part BUT it will not then have the correct mime type and without research I don't know how to make it have the correct mime type. Sorry I can't help.

Bye
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic