× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Can't you use the FileDataSource class to use files as data source?
As in the example below:

      MimeBodyPart mbp3 = new MimeBodyPart();
      DataSource source3 = new FileDataSource("C:\\reynders.gif");
      mbp3.setHeader("Content-ID", "test");
      mbp3.setDataHandler(new DataHandler(source3));

-----Original Message-----
From: Bruce Jin [mailto:brucej@mrc-productivity.com]
Sent: dinsdag 9 oktober 2001 19:15
To: java400-l@midrange.com
Subject: Re: JavaMail: Implement DataSource in javax.activation package


This is a multi-part message in MIME format.
--
In JavaMail download demo folder I found a  ByteArrayDataSource that
implements DataSource of javax.activation.  It works. It allows java program
to send simple dynamic contents as e-mail attachment. I attached this
implementation for those interested.
Bruce

----- Original Message -----
From: "Clapham, Paul" <pclapham@core-mark.com>
To: <java400-l@midrange.com>
Sent: Friday, October 05, 2001 3:19 PM
Subject: RE: JavaMail: Implement DataSource in javax.activation package


> Don't know, I haven't done this myself.  Your getContentType() looks OK to
> me.  I'd have getOutputStream() throw new IOException(), but I doubt it's
> even being called.  Can you make your code work with a FileDataSource?  If
> so, try creating a subclass of FileDataSource and overriding just
> getContentType() with your code.  That would test that potential problem.
> Otherwise, I dunno.
>
> PC2
>
> -----Original Message-----
> From: Bruce Jin [mailto:brucej@MRC-PRODUCTIVITY.COM]
> Sent: October 5, 2001 15:03
> To: java400-l@midrange.com
> Subject: Re: JavaMail: Implement DataSource in javax.activation package
>
>
>  Thanks PC2;
> I wrote a class to implement DataSOurce. Now my JavaMail program runs with
> this InputStreamDataSource. But the attached document is always empty. I
> think I might not have implemented getContentType() and getOutputStream()
> correctly. Here is the implementation class:
>
> import javax.activation.*;
> import java.io.*;
>
>  public class InputStreamDataSource implements DataSource {
>   private InputStream inputStream;
>   private OutputStream outputStream;
>
> public InputStreamDataSource(InputStream inputStream) {
>     this.inputStream = inputStream
> }
> public InputStream getInputStream() {
>     return inputStream
> }
>  public String getContentType() {
>     return "text/plain";                                    //??
> }
> public String getName() {
>     return "aname";
> }
> public OutputStream getOutputStream() { //?
>     return outputStream;
> }
> }
>
> In my java mail class I have the following:
>
>   String aString = "a test string is here";    / / send this as attached
doc
>   byte[] bt = aString.getBytes();
>   InputStream is =  new ByteArrayInputStream(bt);
>  DataSource source = new InputStreamDataSource(is);
>
>  ----- Original Message -----
>
> From: "Clapham, Paul" <pclapham@core-mark.com>
> To: <java400-l@midrange.com>
> Sent: Friday, October 05, 2001 10:58 AM
> Subject: RE: JavaMail: Implement DataSource in javax.activation package
>
>
> > You have only four methods to implement, like this:
> >
> > getContentType(): return a string containing the MIME type of whatever's
> in
> > the input stream.  You'd have to have some way of setting or determining
> > this.
> >
> > getInputStream(): return the input stream that you passed into the
object
> > via its constructor.
> >
> > getName(): probably irrelevant.
> >
> > getOutputStream(): throw an IOException.
> >
> > PC2
> >
> > -----Original Message-----
> > From: Bruce Jin [mailto:brucej@mrc-productivity.com]
> > Sent: October 5, 2001 12:38
> > To: java400-l@midrange.com
> > Subject: JavaMail: Implement DataSource in javax.activation package
> >
> >
> > In my java program I need to send some generated contents as e-mail
> > attachment. But I found that the javax.activation only comes with a
> > FileDataSource that implements DataSource. This can be used to send a
> file:
> >
> > DataSource source = new FileDataSource(filename);
> >
> >  How do I implement DataSource so that I have something like
> > InputStreamDataSource then  I can send some generated contents in my
java
> > program as e-mail attachment?
> >
> >
>
> _______________________________________________
> This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
> mailing list
> To post a message email: JAVA400-L@midrange.com
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
> or email: JAVA400-L-request@midrange.com
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/java400-l.
> _______________________________________________
> This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
> To post a message email: JAVA400-L@midrange.com
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
> or email: JAVA400-L-request@midrange.com
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/java400-l.
>
--
[ ByteArrayDataSource.java of type application/octet-stream deleted ]
--

_______________________________________________
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
To post a message email: JAVA400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
or email: JAVA400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.