Then we need to call the addBodyPart method. We'll need to call it
twice to add the text message and the JPEG attachment.
Then use message.setContent(mimeMultipart).
After that we'll send the Message using Aspirin:
How do we do this? Here's the JavaMail API doc:
I know how to save the BufferedImage object data to a JPEG file on the
hard disk, and how to load the data back out of the file into the email
message, but it makes the program much to slow to write a file on the
hard disk, and we need to figure out how to move the data directly from
the BufferedImage object into the email Message object without using
writing a file - if possible.
Hope it helps,
Constantin
If the Image object were serializable you could use this one:
(JavaMail and JAF)
MimeBodyPart mbp3=new MimeBodyPart();
mbp.setDataHandler(new DataHandler(new
ObjectDataSource(myAWTImage,"image/jpeg")));
maybe you know a way to make BufferedImager serializable.
(ImageIO)
static boolean write(RenderedImage im, String formatName, OutputStream
output)
Unless Images are serializable, I think that I would use the above
function to write the Image into a ByteArrayOutputStream.
Then you need to find or to write a DataSource Implementation which
uses the ByteArray as InputStream.
JavaMail is then able to create the email representation and with
Aspirin you can send it.
Have you checked out if other sourceforge projects could also be useful
for your project like this one:
http://jwma.sourceforge.net/index.html
regards
matjung
with this Instrument you can safe an Image in the memory and deliver an
InputStream for the MimeBodyPart Object.
I tried to upload these files via CVS but the computer tells me that I
need write access for the repository.
I am using TortoiseCVS to communicate with the CVS repository.
it's not memory efficient, but it works.
see the "Getting Started" discussion thread in this group for cvs
access information.
We are receiving a runtime NullPointerException trying to send a text
email through Aspirin 0.6.6 running WitlApp.java :
D:\Java\mycvs\witl\com\isaac4\lgpl\witl>java
com.isaac4.lgpl.witl.WitlApp mye...@hotmail.com
04.08.2005 20:46:48 org.masukomi.aspirin.core.RemoteDelivery deliver
SCHWERWIEGEND: java.lang.NullPointerException
04.08.2005 20:46:48 org.masukomi.aspirin.core.RemoteDelivery deliver
WARNUNG: No mail server found for: hotmail.com
04.08.2005 20:46:48 org.masukomi.aspirin.core.RemoteDelivery
failMessage
WARNUNG: Permanent exception delivering mail
(javax.mail.inte...@1a0c10f-to-hotmail.com:
javax.mail.MessagingException: I found no MX record entries for the
hostname hotmail.com. I cannot determine where to send this message.
at
org.masukomi.aspirin.core.RemoteDelivery.deliver(RemoteDelivery.java:177)
at
org.masukomi.aspirin.core.RemoteDelivery.run(RemoteDelivery.java:486)
at
org.apache.commons.threadpool.DefaultThreadPool.run(DefaultThreadPool.java:156)
at java.lang.Thread.run(Unknown Source)
Of course using DummyMailer instead of DummyTextMailer or
AspirinJpegMailer , specified at the top LightWalker.java works fine-
it just saves a screenshot to the disk. So this doesn't work:
//private MailableImage mailer = new DummyMailer();
//private MailableImage mailer = new DummyTextMailer();
private MailableImage mailer = new AspirinJpegMailer();
And neither does this:
//private MailableImage mailer = new DummyMailer();
private MailableImage mailer = new DummyTextMailer();
//private MailableImage mailer = new AspirinJpegMailer();
But this will:
private MailableImage mailer = new DummyMailer();
//private MailableImage mailer = new DummyTextMailer();
//private MailableImage mailer = new AspirinJpegMailer();