Oups, some problems with the packages in my last patch. Sorry
Here is a correction (to the orginal CVS)

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

? turbine/bin/classes
? turbine/bin/src
? turbine/bin/turbine-2.0.jar
? turbine/src/java/org/apache/turbine/util/mail/HtmlEmail.java
?
turbine/src/java/org/apache/turbine/util/webmacro/WebMacroHtmlEmail.java
Index: turbine/src/java/org/apache/turbine/util/mail/Email.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/util/mail/Email.java,v
retrieving revision 1.6
diff -r1.6 Email.java
81a82
>  * @author Regis Koenig
91d91
<     public static final String ATTACHMENTS = "attachments";
93d92
<     public static final String FILE_SERVER = "file.server";
99a99,100
>     public static final String ATTACHMENTS = "attachments";
>     public static final String FILE_SERVER = "file.server";
101,102c102,140
<       /** The email message to send. */
<       Message message;
---
>     /** The email message to send.
>      */
>     Message message;
> 
>     /* Lists of related email adresses */
>     private Vector toList;
>     private Vector ccList;
>     private Vector bccList;
>     private Vector replyList;
> 
>     private Session getMailSession()
>     {
>       Properties properties = System.getProperties();
>       properties.put ( MAIL_TRANSPORT_PROTOCOL, SMTP );
>       properties.put ( MAIL_HOST, TurbineResources.getString( MAIL_SERVER ) );
>       return Session.getDefaultInstance(properties, null);
>     }
> 
>     
> 
>     /** Initializes the mail.
>      * @deprecated
>      * @see init()
>      */
>     protected void initialize(Criteria criteria)
>       throws MessagingException {
>       init();
>       initCriteria(criteria);
>     }
>     
>     /** Initializes the mail.
>      * <p> This is the first method that should be called by
>      * a sublasse in its constructor;
>      */
>     protected void init()
>       throws MessagingException {
>       
>       // create the message
>       message = new MimeMessage( getMailSession() );
104,136c142,201
<       private Session getMailSession()
<       {
<               Properties properties = System.getProperties();
<               properties.put ( MAIL_TRANSPORT_PROTOCOL, SMTP );
<               properties.put ( MAIL_HOST, TurbineResources.getString( MAIL_SERVER
) );
<               return Session.getDefaultInstance(properties, null);
<       }
<       protected void initialize( Criteria criteria ) throws Exception
<       {
<               // create the message
<               message = new MimeMessage( getMailSession() );
< 
<               // set the FROM field
<               message.setFrom( new InternetAddress( criteria.getString(
SENDER_EMAIL ),
<                                                                                      
   criteria.getString( SENDER_NAME ) ) );
<               // set the TO field
<               message.setRecipient( Message.RecipientType.TO, 
<                                                         new InternetAddress( 
criteria.getString( RECEIVER_EMAIL ),
<                                                                                      
            criteria.getString( RECEIVER_NAME ) ) );
<               // set the SUBJECT field
<               message.setSubject( criteria.getString( EMAIL_SUBJECT ) );
<               
<               // set the sent date
<               message.setSentDate( new Date() );
<       }
<       /**
<        * Does the work of actually sending the email.
<        *
<        * @exception MessagingException if an error
<        */
<       public void     send() throws MessagingException
<       {
<               Transport.send( message );
---
>       toList = new Vector();
>       ccList = new Vector();
>       bccList = new Vector();
>       replyList = new Vector();
> 
>       // set the sent date
>       setSentDate( new Date() );
>     }
> 
>     /** Initialize the mail according to the Criteria
>      * <p>This method uses the criteria parameter to set
>      * the from, to and subject field of the email
>      *
>      * @deprecated One should use the setFrom, addTo, etc. methods
>      */
>     protected void initCriteria( Criteria criteria )
>       throws MessagingException {
>       
>       // set the FROM field
>       if( criteria.containsKey( SENDER_EMAIL) && criteria.containsKey( SENDER_NAME ) 
>)
>           setFrom(criteria.getString( SENDER_EMAIL ), criteria.getString( 
>SENDER_NAME ));
>       // set the TO field
>       if( criteria.containsKey( RECEIVER_EMAIL) && criteria.containsKey( 
>RECEIVER_NAME ) )
>           addTo( criteria.getString( RECEIVER_EMAIL ), criteria.getString( 
>RECEIVER_NAME ) );
>       // set the SUBJECT field
>       if( criteria.containsKey( EMAIL_SUBJECT ) )
>           setSubject( criteria.getString( EMAIL_SUBJECT ) );
>     }
> 
>     /** Set the FROM field of the email
>      */
>     public Email setFrom(String email, String name )
>       throws MessagingException {
> 
>       try {
>           if( (name == null) || (name.trim().equals("")) ) {
>               name = email;
>           }
>           message.setFrom(new InternetAddress( email, name ) );
>       }
>       catch( Exception e ) {
>           throw new MessagingException("cannot set from", e);
>       }
>       return this;
>     }
> 
> 
>     /** Add a recipient TO to the email
>      */
>     public Email addTo(String email, String name )
>       throws MessagingException {
> 
>       try {
>           if( (name == null) || (name.trim().equals("")) ) {
>               name = email;
>           }
>           toList.add( new InternetAddress( email, name ) );
>       }
>       catch( Exception e ) {
>           throw new MessagingException("cannot add to", e);
137a203,301
>       return this;
>     }
> 
>     /** Add a recipient CC to the email
>      */
>     public Email addCc(String email, String name )
>       throws MessagingException {
> 
>       try {
>           if( (name == null) || (name.trim().equals("")) ) {
>               name = email;
>           }
>           ccList.add( new InternetAddress( email, name ) );
>       }
>       catch( Exception e ) {
>           throw new MessagingException("cannot add cc", e);
>       }
> 
>       return this;
>     }
> 
>     /** Add a blind CC repcipient to the email
>      */
>     public Email addBcc(String email, String name )
>       throws MessagingException {
> 
>       try {
>           if( (name == null) || (name.trim().equals("")) ) {
>               name = email;
>           }
>           bccList.add( new InternetAddress( email, name ) );
>       }
>       catch( Exception e ) {
>           throw new MessagingException("cannot add bcc", e);
>       }
> 
>       return this;
>     }
> 
>     /** Add a reply to address to the email
>      */
>     public Email addReplyTo(String email, String name )
>       throws MessagingException {
> 
>       try {
>           if( (name == null) || (name.trim().equals("")) ) {
>               name = email;
>           }
>           replyList.add( new InternetAddress( email, name ) );
>       }
>       catch( Exception e ) {
>           throw new MessagingException("cannot add replyTo", e);
>       }
> 
>       return this;
>     }
> 
>     /** Set the email subject
>      */
>     public Email setSubject( String subject )
>       throws MessagingException {
>       
>       message.setSubject(subject);
>       return this;
>     }
> 
>     /** Set the sent date field
>      */
>     public Email setSentDate( Date date )
>       throws MessagingException {
>       
>       message.setSentDate( date );
>       return this;
>     }
> 
>     /** Define the content of the mail
>      * <p>should be overidden by the sublcasses
>      */
>     public abstract Email setMsg(String msg)
>       throws MessagingException;
>       
>     /**
>      * Does the work of actually sending the email.
>      *
>      * @exception MessagingException if an error
>      */
>     public void       send()
>       throws MessagingException {
> 
>       InternetAddress[] foo = new InternetAddress[0];
>       message.setRecipients(Message.RecipientType.TO,
>                             (InternetAddress[])toList.toArray(foo));
>       message.setRecipients(Message.RecipientType.CC,
>                             (InternetAddress[])ccList.toArray(foo));
>       message.setRecipients(Message.RecipientType.BCC,
>                             (InternetAddress[])bccList.toArray(foo));
>       message.setReplyTo((InternetAddress[])replyList.toArray(foo));
>       Transport.send( message );
>     }
Index:
turbine/src/java/org/apache/turbine/util/mail/EmailAttachment.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/util/mail/EmailAttachment.java,v
retrieving revision 1.1
diff -r1.1 EmailAttachment.java
56a57,58
> 
> import java.net.URL;
64a67,69
>     public final static String ATTACHMENT = javax.mail.Part.ATTACHMENT;
>     public final static String INLINE = javax.mail.Part.INLINE;
>     
70a76,79
>     /** The HttpURI where the file can be got */
>     private URL url = null;
>     /** The disposition */
>     private String disposition = ATTACHMENT;
83a93,98
>     public URL getURL() {
>       return url;
>     }
>     public String getDisposition() {
>       return disposition;
>     }
96c111,117
< }
\ No newline at end of file
---
>     public void setURL(URL url) {
>       this.url = url;
>     }
>     public void setDisposition(String disposition) {
>       this.disposition = disposition;
>     }
> }
Index: turbine/src/java/org/apache/turbine/util/mail/MailMessage.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/util/mail/MailMessage.java,v
retrieving revision 1.2
diff -r1.2 MailMessage.java
1d0
< 
70,71c69,70
< /**
<  * MailMessage creates a very simple text/plain message and sends
it.<br>
---
> /** Creates a very simple text/plain message and sends it.
>  * <p>MailMessage creates a very simple text/plain message and sends it.<br>
79c78
<  *<br>
---
>  * <br>
93c92
<  *<br>
---
>  * <br>
Index: turbine/src/java/org/apache/turbine/util/mail/MultiPartEmail.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/util/mail/MultiPartEmail.java,v
retrieving revision 1.6
diff -r1.6 MultiPartEmail.java
71a72
> //import org.apache.turbine.util.mail.*;
73,74c74,75
< /**
<  * This class is used to send multi-part internet email
---
> /** A multipart email
>  * <p>This class is used to send multi-part internet email
77,93c78,80
<  * To create a multi-part email you need to pass a Criteria
<  * object into the MultiPartEmail constructor which contains:
<  * <p>
<  * SENDER_EMAIL<br>
<  * SENDER_NAME<br>
<  * RECEIVER_EMAIL<br>
<  * RECEIVER_NAME<br>
<  * EMAIL_SUBJECT<br>
<  * EMAIL_BODY<br>
<  * ATTACHMENTS - a Vector containing EmailAttachment objects<p>
<  *
<  * Optionally you can pass in:
<  * <p>
<  * FILE_SERVER
<  * <p>
<  * If you do not this class will assume that the file you are 
<  * looking for is on the machine this code is running on.
---
>  * <p>To create a multi-part email, call the default constructor
>  * and then you can call setMsg() to set the message and
>  * call the different attach() methods.
97a85
>  * @author Regis Koenig
99a88
> 
101,122c90,177
<     Multipart emailBody;
<     /**
<      * Constructor used to initialize attributes.
<      */
<     public MultiPartEmail( Criteria criteria ) throws Exception
<     {
<         super.initialize( criteria );
<         this.init( criteria );
<     }
<     private void init( Criteria criteria ) throws MessagingException,
IOException
<     {
<         // create the text for the body
<         MimeBodyPart main = new MimeBodyPart();
<         main.setText( criteria.getString( EMAIL_BODY ) );
<         
<         // add the parts to the body
<         Multipart body = new MimeMultipart();
<         body.addBodyPart( main );
<         
<         Vector attachments = (Vector)criteria.get( ATTACHMENTS );
<         for (int i=0; i<attachments.size(); i++)
<         {
---
>     protected MimeMultipart emailBody;
> 
>     /** The message container */ 
>     protected MimeBodyPart main;
> 
>     /** The file server if it exists */ 
>     private String fileServer = null;
> 
>     /** Initialize the multipart email
>      */
>     public MultiPartEmail()
>       throws MessagingException {
>       this.init();
>     }
>     
>     /** Constructor used to initialize attributes.
>      * <p> This method uses the criteria object to set the different
>      *   fields of the e-mail. The expected fields of the Criteria are:
>      * <li>SENDER_EMAIL
>      * <li>RECEIVER_EMAIL
>      * <li>EMAIL_SUBJECT
>      * <li>EMAIL_BODY
>      * <li>ATTACHMENTS - a Vector of EmailAttachment
>      * <li>FILE_SERVER - where the files are located. If not given, they are
>      *   assumed to be local.
>      *
>      * @deprecated  since Criteria is deprecated in mail API
>      */
>     public MultiPartEmail( Criteria criteria )
>       throws MessagingException {
>       this.init();
>       this.initCriteria(criteria);
>     }
> 
>     /** Initialize the multipart email
>      */
>     protected void init()
>       throws MessagingException {
>       
>       super.init();
> 
>       fileServer = null;
>       
>       /* The body of the mail */
>       emailBody = new MimeMultipart();
>       //emailBody.setSubType("attachement");
>       message.setContent( emailBody );
> 
>       /* The main message content */
>       main = new MimeBodyPart();
>       emailBody.addBodyPart(main);
>     }
> 
> 
>     /** Uses the criteria to set the fields
>      * <p> This methos uses the criteria object to set the different
>      * fields of the e-mail. The expected fields of the Criteria are:
>      * <li>SENDER_EMAIL
>      * <li>RECEIVER_EMAIL
>      * <li>EMAIL_SUBJECT
>      * <li>EMAIL_BODY
>      * <li>ATTACHMENTS - a Vector of EmailAttachment
>      * <li>FILE_SERVER - where the files are located. If not given, they are
>      *   assumed to be local.
>      *
>      * @deprecated since the Criteria is deprecated
>      */
>     protected void initCriteria( Criteria criteria )
>       throws MessagingException {
> 
>       super.initCriteria(criteria);
> 
>       if( criteria.containsKey( EMAIL_BODY ) )
>           setMsg( criteria.getString( EMAIL_BODY ) );
>       else
>           setMsg("NO MESSAGE");
>       
>       Vector attachments;
>       
>       if( criteria.containsKey(ATTACHMENTS ) )
>           attachments = (Vector)criteria.get( ATTACHMENTS );
>       else
>           attachments = new Vector();
>       
>       if( criteria.containsKey(FILE_SERVER) )
>           fileServer = criteria.getString(FILE_SERVER);
>       
>         for (int i=0; i<attachments.size(); i++) {
124,143c179
<             
<             String file = attachment.getPath();
<             String mimeType = new
MimetypesFileTypeMap().getContentType(file);
<             URL url = null;
<             
<             if ( criteria.containsKey(FILE_SERVER) )
<                 url = new URL( "file",
criteria.getString(FILE_SERVER), file );
<             else
<                 url = new URL( "file", null, file );
<             
<             // create the attachment(s) and add them to the body
<             MimeBodyPart mbp = new MimeBodyPart();
<             mbp.setDisposition( Part.ATTACHMENT );
<             mbp.setFileName ( attachment.getName() );
<             mbp.setDescription ( attachment.getDescription() );
<             mbp.setDataHandler ( new DataHandler( new
URLDataSource(url) ) );
<             
<             //new ByteArrayDataSource( url.openStream(), mimeType ) )
);
<            
<             body.addBodyPart( mbp );
---
>           attach( attachment );
145,147c181,240
<     
<         // set the email body
<         message.setContent( body );
---
>     }
> 
>     /** Set the message of the email
>      */
>     public Email setMsg(String msg)
>       throws MessagingException {
> 
>       main.setText(msg);
>       return this;
>     }
> 
>     /** attach an EmailAttachement
>      */
>     public MultiPartEmail attach( EmailAttachment attachment )
>       throws MessagingException {
> 
>       URL url = attachment.getURL();
>       if( url == null ) {
>           try {
>               String file = attachment.getPath();
>               url = new URL( "file", fileServer, file );
>           }
>           catch( Exception e) {
>               throw new MessagingException("Cannot find file", e);
>           }
>       }
>       
>       return attach(url, attachment.getName(),
>                     attachment.getDescription(), attachment.getDisposition() );
>     }
> 
>     /** Attach a file located by its url.
>      * <p> The disposition of the file is set to mixed
>      */
>     public MultiPartEmail attach( URL url, String name, String description)
>       throws MessagingException {
>       
>       return attach( url, name, description, EmailAttachment.ATTACHMENT);
>     }
> 
>     /** Attach a file located by its url
>      * @param url the URL of the file (may be any valid URL)
>      * @param name the name field for the attachment
>      * @param description a description for the attachement
>      * @param disposition either mixed or inline
>      *
>      */
>      public MultiPartEmail attach( URL url, String name, String description, String 
>disposition)
>       throws MessagingException {
> 
>       MimeBodyPart mbp = new MimeBodyPart();
>       emailBody.addBodyPart( mbp );
>       
>       mbp.setDisposition( disposition );
>       mbp.setFileName ( name );
>       mbp.setDescription ( description );
>       mbp.setDataHandler ( new DataHandler( new URLDataSource(url) ) );
> 
>       return this;
> 
Index: turbine/src/java/org/apache/turbine/util/mail/SimpleEmail.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/util/mail/SimpleEmail.java,v
retrieving revision 1.3
diff -r1.3 SimpleEmail.java
76,85d75
<  * To create a simple email you need to pass a Criteria
<  * object into the SimpleEmail constructor which contains:
<  * <p>
<  * SENDER_EMAIL<br>
<  * SENDER_NAME<br>
<  * RECEIVER_EMAIL<br>
<  * RECEIVER_NAME<br>
<  * EMAIL_SUBJECT<br>
<  * EMAIL_BODY<br>
<  *
88a79
>  * @author Regis Koenig
90,94c81,84
< public class SimpleEmail extends Email {
<     /** Body portion of the email. */
<     String emailBody;
<     /**
<      * Constructor used to initialize attributes.
---
> public class SimpleEmail
>     extends Email {
> 
>     /** Default constructor
96,99c86,88
<     public SimpleEmail( Criteria criteria ) throws Exception
<     {
<         super.initialize( criteria );
<         this.init( criteria );
---
>     public SimpleEmail()
>       throws MessagingException {
>       super.init();
101,104c90,122
<     private void init( Criteria criteria ) throws MessagingException
<     {
<         // set the email body
<         message.setContent( criteria.getString( EMAIL_BODY ),
TEXT_PLAIN );
---
>     
>     /** Constructor used to initialize attributes.
>      * <p>To create a simple email you need to pass a Criteria
>      * object into the SimpleEmail constructor which contains:
>      * <li>SENDER_EMAIL
>      * <li>SENDER_NAME
>      * <li>RECEIVER_EMAIL
>      * <li>RECEIVER_NAME
>      * <li>EMAIL_SUBJECT
>      * <li>EMAIL_BODY
>      * @deprecated since Criteria is deprecated in mail API
>      */
>     public SimpleEmail( Criteria criteria )
>       throws MessagingException {
>       super.init();
>       this.initCriteria(criteria);
>     }
>     
>     protected void initCriteria( Criteria criteria )
>       throws MessagingException {
> 
>       if( criteria.containsKey( EMAIL_BODY ) ) 
>           setMsg( criteria.getString( EMAIL_BODY ) );
>       else
>           setMsg("NO MESSAGE");
>     }
> 
>     /** Set the content of the mail
>      */
>     public Email setMsg( String msg )
>       throws MessagingException {
>       message.setContent( msg, TEXT_PLAIN );
>       return this;
Index:
turbine/src/java/org/apache/turbine/util/webmacro/WebMacroEmail.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/util/webmacro/WebMacroEmail.java,v
retrieving revision 1.4
diff -r1.4 WebMacroEmail.java
187,194c187,191
<             Criteria crit = new Criteria();
<             crit.add ( Email.SENDER_EMAIL, fromEmail );
<             crit.add ( Email.SENDER_NAME, fromName );
<             crit.add ( Email.RECEIVER_EMAIL, toEmail );
<             crit.add ( Email.RECEIVER_NAME, toName );
<             crit.add ( Email.EMAIL_SUBJECT, subject );
<             crit.add ( Email.EMAIL_BODY, body );        
<             SimpleEmail se = new SimpleEmail(crit);
---
>             SimpleEmail se = new SimpleEmail();
>           se.setFrom(fromEmail, fromName);
>           se.addTo(toEmail, toName);
>           se.setSubject(subject);
>           se.setMsg(body);


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to