jBPM mail nodes are simple nodes designed only to send mails. This time you don’t have to implement any handler or function, jBPM libraries provide nearly all you need.
In mail info tab you can set the destination e-mail address, the subject and the mail body that is going to send. This will be useful when you know destination e-mail address, orders@mycompany.com, for instance.
If you need to send mails to workflow actors, you can set a user variable in context:
executionContext.setVariable("user", workflowActor);
and configure mail info as it follows:
jBPM address resolver will check for user e-mail address from database and send him the mail, you will have to do nothing!
This is a great node but I had some requirements that it didn’t provide to me, so I re-implemented it, adding some new methods.
You can download new implementation here.
Now I can send mails using a gmail account. To explain it in a simple way, my implementation read some extra parameters from jbpm.cfg.xml file before sending the mail.
<string name="jbpm.mail.smtp.host" value="smtp.gmail.com" /> <bean name="jbpm.mail.address.resolver" class="org.jbpm.identity.mail.IdentityAddressResolver" singleton="true" /> <string name="jbpm.mail.from.address" value="yourMail@gmail.com" /> <string name="jbpm.mail.user" value="yourUser@gmail.com" /> <string name="jbpm.mail.pass" value="yourPassword" /> <string name="jbpm.mail.port" value="465" /> <string name="jbpm.mail.smtp.socketFactory.port" value="465" /> <string name="jbpm.mail.smtp.socketFactory.class" value="javax.net.ssl.SSLSocketFactory" /> <string name="jbpm.mail.smtp.auth" value="true" /> <string name="jbpm.mail.smtp.starttls.enable" value="true" /> <string name="jbpm.mail.debug" value="true" /> <string name="jbpm.mail.smtp.socketFactory.fallback" value="false" /> <string name="jbpm.mail.advanced.config" value="true" /> <string name='mail.class.name' value='FastSign.mail.Mail' />
If jbpm.mail.advanced.config is set to false it works as the original mail node. Setting it to true, activates the extra parameters. In this case, 465 is gmail port, I suppose you can change it to use other system. Note that you have to define mail.class.name with the correct package.
I hope this will be useful.



April 3rd, 2008 at 2:45 pm
Hi,
you are doing here a nice work! Thanks!
One question, we can put some variable in the context like you have made:
executionContext.setVariable(”user”, workflowActor);
But do you know how to delete one?
Thanks
Marques
April 3rd, 2008 at 3:09 pm
so i’ve found…
it’s executionContext.getProcessInstance().getContextInstance().deleteVariable(”STRING”);
if someone need it like me ^-^
April 4th, 2008 at 1:30 pm
hi,
so now I’ve the problem that he doesn’t accept
executionContext.setVariable(”Variable”, myVariable);
do you have an idea?
thanks
April 4th, 2008 at 1:32 pm
hi,
so now I’ve the problem that he doesn’t accept
executionContext.setVariable(”Variable”, myVariable);
he makes an exception in hibernateException:
instance not of expected entity type: org.jbpm.conext.exe.variableInstance
do you have an idea?
i tried to convert myVariable to the type object but the errer persists…
thanks
April 4th, 2008 at 2:42 pm
What kind of type are you using? You can’t no use simple types like int. String, Integer, etc are working correctly in my projects
April 4th, 2008 at 3:01 pm
hi,
i’m using a type that i’ve defined.
example:
MyVar MVar = new MyVar(executionContext);
executionContext.setVariable(”MVar”,MVar);
but it seems to work.
I’ve tried also with String, int and with this types I had no problem.
After this I tried with executionContext.setVariable(”MVar”,MVar.toString());
and it works…but I have other problems…
and I don’t know if I can receive my variable back…
April 4th, 2008 at 3:26 pm
Does your class implements Seriarizable? You must implement it if you want hibernate save/reconstruct your objects.
April 4th, 2008 at 4:55 pm
no she was not seriarizable…that was the fault…
thanks
July 3rd, 2008 at 6:44 pm
Hi pigui, nice job, thanks to post informations to help other people.
Please, could you give a little help, somethings are not very clear to me.
When I create a new jBpm project, the jbpm.cfg.xml file is created automatically in the root of the claspath and it came empty, so uses the file org/jbpm/default.jbpm.cfg.xml to get the informations needed, right?
When I fill the jbpm.cfg.xml file with the informations that you wrote above (jbpm.mail.smtp.host, jbpm.mail.port, …) will my process automatically get the informations from the jbpm.cfg.xml file and not more from org/jbpm/default.jbpm.cfg.xml?
My jBPM version is 3.2.2.
Thank you
Regards
July 4th, 2008 at 8:14 am
@Fornachari
Hi Fornachari.
I’m always creating my complete config file and placing it inside my project.
You can load it using this function:
static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseResource( “ProjectName/config/jbpm.cfg.xml”);
I hope it helps you.