Hi every body
Sorry for my english.
I'm tryn to fetch an image from url, and then send it via mail;
this is my code:
String url = "
http://www.google.co.ve/images/firefox/
globe_getinvolved.png"
String contenttype ;
URL myurl = new URL(url);
HttpURLConnection conn = (HttpURLConnection) myurl.openConnection();
contenttype = conn.getContentType();
Object image = conn.getContent();
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("
XX...@gmail.com","Admin"));
msg.addRecipient(
Message.RecipientType.TO,"
XX...@gmail.com");
msg.setSubject(url);
MimeBodyPart ad = new MimeBodyPart();
ByteArrayDataSource src = new
ByteArrayDataSource((InputStream)image,contenttype);
ad.setDataHandler(new DataHandler(src));
Multipart mp = new MimeMultipart();
mp.addBodyPart(ad);
msg.setContent(mp);
Transport.send(msg);
The problem is when i do the cast to the object
'image' (InputStream)image ; How can i do to convert the result of the
conn.getContent(); to an InputStream or to a byte[].
Thanks