Hi guys

I have the following process:


  | <process-definition
  |   xmlns="urn:jbpm.org:jpdl-3.1"  name="sendmail">
  |    <start-state name="Inicio">
  |       <transition name="" to="Send Mail"></transition>
  |    </start-state>
  |    <end-state name="Fim"></end-state>
  |    <node name="Send Mail">
  |             <action class="test.MailMeActionHandler"></action>
  |       <transition name="" to="Fim"></transition>
  |    </node>
  | </process-definition>
  | 

And the following action handler:


  | package pep.test;
  | 
  | import org.jbpm.graph.def.ActionHandler;
  | import org.jbpm.graph.exe.ExecutionContext;
  | //import java.util.Properties;
  | //import javax.mail.*;
  | //import javax.mail.internet.*;
  | import java.io.*;
  | 
  | public class MailMeActionHandler implements ActionHandler {
  | 
  |     private static final long serialVersionUID = 1L;
  |     
  |     public void execute(ExecutionContext context) throws Exception {
  |             
  |             
  |             /* Tenta enviar o e-mail*/
  |             
  |        String host = "smtp.myserver.com";
  |         String from = "[EMAIL PROTECTED]";
  |         String to = "[EMAIL PROTECTED]";
  |      
  |             try {
  |                 // Get system properties
  |                 Properties props = System.getProperties();
  |             
  |                 // Setup mail server
  |                 Authenticator auth = new PopupAuthenticator();
  |                 props.put("mail.smtp.host", host);
  |                 props.put("mail.smtp.auth", "true");
  |                 
  |                 // Get session
  |                 Session session = Session.getInstance(props, auth);
  |                 session.setDebug(true);
  |                 //session.setDebug(true);
  |             
  |                 
  |                 
  |                 // Define message
  |                 MimeMessage message = new MimeMessage(session);
  |             
  |                 
  |                 // Set the from address
  |                 message.setFrom(new InternetAddress(from,"Ricardo 
Marques"));
  |             
  |                 // Set the to address
  |                 message.addRecipient(Message.RecipientType.TO,new 
InternetAddress(to,"Ricardo Marques"));
  |             
  |                 // Set the subject
  |                 message.setSubject("Hello JavaMail");
  |             
  |                 // Set the content
  |                 message.setText("Welcome to JavaMail");
  |             
  |                 // Send message
  |                 Transport.send(message);
  |                 System.out.println("OK Man");
  |              }
  |              catch (Exception e) {
  |                  e.printStackTrace();
  |          }
  |              
  |              context.leaveNode();
  |             
  |     }
  |     
  |     static class PopupAuthenticator extends Authenticator {
  |         public PasswordAuthentication getPasswordAuthentication() {
  |             return new PasswordAuthentication("[EMAIL PROTECTED]", 
"******");
  |         }
  |     }
  | 
  | }
  | 

But just can't see the result of the execution, or any kind of error. On the 
process instances table, it appears a record about the execution, but nothing 
else.

The mail code, detach from the jbpm enviromnent, it works, so I suppose that 
should work on the enviroment.

I want to start the process and receive a e-mail.

Please need some help..!

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4046768#4046768

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4046768
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to