Changeset 422 for tapas/common


Ignore:
Timestamp:
03/19/12 18:39:02 (12 years ago)
Author:
vmipsl
Message:

Envoi mail
Correctif annontation Id
properties

Location:
tapas/common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tapas/common/implementation/com/ether/EtherHelper.java

    r417 r422  
    44import org.jetbrains.annotations.NotNull; 
    55import org.jetbrains.annotations.Nullable; 
    6  
     6import org.springframework.mail.javamail.JavaMailSenderImpl; 
     7import org.springframework.mail.javamail.MimeMessageHelper; 
     8 
     9import javax.mail.MessagingException; 
     10import javax.mail.internet.MimeMessage; 
    711import java.io.BufferedWriter; 
    812import java.io.FileWriter; 
     
    216220        } 
    217221    } 
     222 
     223    /** 
     224     * This method sends a message 
     225     * host (see in properties) : mailhost.ipsl.jussieu.fr 
     226     * 
     227     * @param host 
     228     * @param to 
     229     * @param from 
     230     * @param subject 
     231     * @param text 
     232     * @throws FormattedException 
     233     */ 
     234    public static void sendMessage( @NotNull final String host, @NotNull final String from, @NotNull final String to, @NotNull final String subject, @NotNull final String text ) 
     235            throws FormattedException 
     236    { 
     237        try 
     238        { 
     239            final JavaMailSenderImpl sender = new JavaMailSenderImpl(); 
     240            sender.setHost( host ); 
     241 
     242            final MimeMessage message = sender.createMimeMessage(); 
     243            final MimeMessageHelper helper = new MimeMessageHelper( message ); 
     244            helper.setFrom( from ); 
     245            helper.setTo( to ); 
     246            helper.setSubject( subject ); 
     247            helper.setText( text ); 
     248            sender.send( message ); 
     249        } 
     250        catch( MessagingException e ) 
     251        { 
     252            throw new FormattedException( FormattedException.FormattedCode.ERROR_TO_SEND_MESSAGE, e ); 
     253        } 
     254    } 
    218255} 
  • tapas/common/interface/com/ether/FormattedException.java

    r417 r422  
    9090    { 
    9191        ERROR_IO_TO_EXECUTE_PROCESS, 
     92        ERROR_TO_SEND_MESSAGE, 
    9293    } 
    9394 
Note: See TracChangeset for help on using the changeset viewer.