Send attachments with mail
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2011 06:07 AM
Is it possible to send attachments to mail using <input type="file"> value?
I have uploaded a file in a form using
<input type="file" name="datafile" size="40">
Now i want to send that file in mail using service task.
How to do it?
Any idea.
Thanks,
Kv
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2011 03:39 AM
Now i can get you.
So how can i write a class for mail with attachment ?
Is the class " org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior" enough or which class i should use for using Commons email technique.
For attachment using commons email i found the code from the link http://commons.apache.org/email/userguide.html.
Where can i write the code and how can i assign values for the fields in the class?
Kindly help me out.
Thanks,
kavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2011 05:44 AM
But it is very easy to write your own (or extends the existing) ActivityBehaviour to do that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2011 06:14 AM
I dont no how to write my own being new to activiti.
I have my own code. But where to include my code in java service task?
Thanks,
kavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2011 06:50 AM
serviceTask id="javaService"
name="My Java Service Task"
activiti:class="org.activiti.MyJavaDelegate" />
public class ToUppercase implements JavaDelegate {
public void execute(DelegateExecution execution) throws Exception {
String var = (String) execution.getVariable("input");
var = var.toUpperCase();
execution.setVariable("input", var);
}
}
You can read all this is the userguide, examples are included as unit-tests… That should do to get you started
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2011 08:14 AM
I have created a class for mail attachment and wrote the code in myname.java.
In service task i included
<serviceTask completionQuantity="1" activiti:class="mailattachment" id="sid-1430FC68-FA04-41E0-9EDB-A9A0329F42A3" implementation="webService" isForCompensation="false" name="Email to applicant on status "OnHold"" startQuantity="1">….
But when i run my process when it comes to this service it says "05280002 Wrapped Exception (with status template): couldn't instantiate class mailattachment ".
When i searched in forum i found that i should include the file in as jar in "activiti\apps\apache-tomcat-6.0.32\webapps\activiti-rest\WEB-INF\lib" .
How to create jar file for .java file.?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2011 08:26 AM
When i tried to build my java file it says
package org.apache.commons.mail does not exist
import org.apache.commons.mail.EmailException;
What am i missing?
Thanks,
kavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2011 09:00 AM
I am not able to compile any of the java file present in
C:\activiti\workspace\activiti-engine-examples\src\main\java\org\activiti\examples\bpmn\servicetask.
It says import error. It seems the lib reference is missing.
How to include reference. Eg:import org.activiti.engine.delegate.Expression; says cannot find org.activiti.engine.delegate.
So how to compile this?
Thanks
kavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2011 06:24 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2012 09:10 AM
-As suggested by you,I tried implementing the Business logic in my java service task via commons email.
-Created 1 attachment field in the bpmn20.xml file as:- <activiti:formProperty id="attachment to be provided" expression="${attachment}" name="attachment" type="string" required="false"/>
-Next I tried to modify the source code via MailActivityBehavior class.
This is throwing me an error as(partially quoted) :
Caused by: org.activiti.engine.ActivitiException: couldn't find type for org.apache.commons.mail.EmailAttachment@60e2ecb3
at org.activiti.engine.impl.variable.DefaultVariableTypes.findVariableType(DefaultVariableTypes.java:62)[113

at org.activiti.engine.impl.persistence.entity.VariableScopeImpl.createVariableLocal(VariableScopeImpl.java:223)[113

at org.activiti.engine.impl.persistence.entity.VariableScopeImpl.setVariable(VariableScopeImpl.java:175)[113

at com.causeway.Example.MailInit.execute(MailInit.java:47)[149:activiti-examples:1.0.0.SNAPSHOT]
at org.activiti.engine.impl.delegate.JavaDelegateInvocation.invoke(JavaDelegateInvocation.java:34)[113

at org.activiti.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:37)[113

at org.activiti.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:25)[113

at org.activiti.engine.impl.bpmn.behavior.ServiceTaskJavaDelegateActivityBehavior.execute(ServiceTaskJavaDelegateActivityBehavior.java:49)[113

at org.activiti.engine.impl.bpmn.behavior.ServiceTaskJavaDelegateActivityBehavior.execute(ServiceTaskJavaDelegateActivityBehavior.java:40)[113

at org.activiti.engine.impl.bpmn.helper.ClassDelegate.execute(ClassDelegate.java:115)[113

Please let me know the type for email attachment to be according to the error?
Grateful if you could provide your email id.
Thanks in advance!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2012 09:20 AM
It looks like you try to set a variable of type EmailAttachment in the process instance context, is that right?
You can't do that because EmailAttachment doesn't implement the Serializable interface. Therefore this error message.
Best regards,
Tijs
