Package ProblemDomainComponent

Examples of ProblemDomainComponent.systemMailClass


   
        try{
           
            persistentObjectManagerClass persistentObjectManager = new persistentObjectManagerClass( configuration, log );           
           
            systemMailClass mail = new systemMailClass();
           
            persistentObjectManager.createNew4( mail );
           
            mail.setMail_from( "alejandrovazquez@yahoo.com" );                   
            mail.setMail_recipient( "avazquez@ferromex.com.mx" );
            mail.setMail_subject( "Test Mailer" );
            mail.setMail_data( "The test ...." );
            mail.setMail_data_type( "text/plain" )// MIME type: csv, html etc... hint for browser to open a viewer...
           
            persistentObjectManager.push_back4( mail );   
           
        } catch (KExceptionClass error ) {
           
View Full Code Here


                        while( query.fetch() ){

                            log.log( this, ">>>Sending Mail ..." + query.getField( "mail_id" ) );

                            // materializeObject
                            systemMailClass mail = transaction1.getEntityManager().find( systemMailClass.class, KMetaUtilsClass.getIntegralNumericValueFromString( query.getField( "mail_id" ) ) );


                            // send
                            try{

                                // configure session

                                    Properties props = new Properties();

                                    props.put("mail.smtp.host", configuration.getField( "mail_server_address" ) );

                                // for GMAIL

                                    // TLS si est disponible
                                    // props.put("mail.smtp.starttls.enable", "true");

                                    // Puerto de gmail para envio de correos
                                    // props.setProperty("mail.smtp.port","587");

                                    props.put("mail.smtp.auth", configuration.getField( "mail.smtp.auth" ) );

                                // get a session

                                    Session session = Session.getInstance( props, null );
                                    session.setDebug( false );

                                // make a message object

                                    MimeMessage mailMessage = new MimeMessage( session );

                                    mailMessage.setFrom(new InternetAddress( mail.getMail_from() ) );

                                    // set recipients
                                    StringTokenizer recipients = new StringTokenizer( mail.getMail_recipient(), "," , false );                                                                                       
                                    int totalRecipients = recipients.countTokens();                                           
                                    InternetAddress[] address = new InternetAddress[ totalRecipients ];                                           
                                    for( int index = 0; index < totalRecipients; index++ ){
                                        String nextRecipient = recipients.nextToken().trim();
                                        address[ index ] = new InternetAddress( nextRecipient );
                                        log.log( this, "Setting recipient [" + nextRecipient + "]" );                                               
                                    }


                                    mailMessage.setRecipients( Message.RecipientType.TO, address );   

                                    mailMessage.setSubject( mail.getMail_subject() );
                                    mailMessage.setSentDate( new Date() );

                                    // create and fill the first message part
                                    MimeBodyPart mailPart1 = new MimeBodyPart();
                                    mailPart1.setContent( mail.getMail_data(), mail.getMail_data_type() );

                                    // create the Multipart and its parts to it
                                    Multipart messageMultipartContainer = new MimeMultipart();
                                    messageMultipartContainer.addBodyPart( mailPart1 );

                                    // add the Multipart to the message
                                    mailMessage.setContent( messageMultipartContainer );

                                // connect

                                    SMTPTransport transport = (SMTPTransport) session.getTransport( "smtp" );

                                // send

                                    if( configuration.getField( "mail.smtp.auth" ).equals( "true" ) ){

                                        transport.connect(
                                                configuration.getField( "mail_server_address" ) ,
                                                configuration.getField( "mail_server_user" ),
                                                configuration.getField( "mail_server_password" )
                                                );

                                    }else{

                                        transport.connect();                                               
                                    }

                                    transport.sendMessage( mailMessage, mailMessage.getAllRecipients() );                                                                               

                                    log.log( this, "Sending Mail ... done!" );  

                                    // update status                               
                                    mail.setMail_status( systemMailClass.STATUS_SENT );                                       

                            // send catch
                            }catch( Exception error ){

                                // update status                               
                                mail.setMail_status( systemMailClass.STATUS_ERROR );
                                mail.setMail_status_description( error.toString() );                                   
                                log.log( this, KMetaUtilsClass.getStackTrace( error ) );

                            }

View Full Code Here

TOP

Related Classes of ProblemDomainComponent.systemMailClass

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.