Sending an attachment using Email Activity (in SOA 11.1.1.5) is an easy task. All you have to do is drag and drop an email activity and double click on it. Assign the following parameters and the attachment will be sent along with the email.
Name- Name of the attachment as it should appear
MimeType- This MimeType is for attachment. Choose appropriate MimeType from here.
Value - Write what you would like to see in the attachment. Simply hard coding.
Well, sometimes the requirement may be to send some custom data, may be you fetched some data at runtime from the DB and would lke to send it as attachment. This isn't complex either, all you have to do is modify the ContentBody parameter as follows. You can do this successfully from the EmailParamsAssign Activity but don't forget to verify the same in the bpel source too.
Extending this a bit further, if you'd like to send some files (image,pdf,doc,xls,csv) that are already stored at some server location or you may have written them from your process, follow these steps.
1.) Set the appropriate MimeType for the file.
2.) Add the following line in the .bpel source under appropriate BodyPart.
3.) Add another copy operation in the bpel source to assign string('base64') to ContentEncoding in BodyPart[2].
4.) Modify the
ContentBody parameter to read the file at runtime using ora:readFile() function as follows.
Key Points to Note:
The above solution works with all the files. Should anyone need the working project, I can mail the same.
- The file location and name in ora:readFile() above are case-sensitive.
- Specifying the correct MimeType is very important. If the MimeType is incorrect, either the mail won't go or you may get encrypted characters in the attached file.
- file:/// (three slashes mean absolute path and two slashes mean relative path)
The above solution works with all the files. Should anyone need the working project, I can mail the same.
Hi,
ReplyDeleteMy name is suri. Nice to see this but bit difficult to go and do it in source level. So could you plz give me the steps in design view.
Thanks
Suri
Hi,
ReplyDeleteNice example. Can you pls post me the code @ crazypassionriders@gmail.com.
Thnx
Hi,
ReplyDeleteVery nice example.I have a requirement where File adapter read file as an attachment and need to send the same through email attachment.
In this case the file is attaching in the mail but the content is not displaying is there a way to get it.
Thanks,
Ezhilan.
Mail:ezhil3487@gmail.com
Thanks Ezhilan!
DeleteI haven't tried this but it must be around the content-encoding. I think File Adapter reads the attachment in binary. If somehow you can convert the binary content to base64, the solution should work.
Let me know how it goes. I'll see to implement the same and will update here.
Hi Radha, good morning. i have same requirement..i have read the file from ftp and send the same as an attachment. but when i am reading the file as an attachment it is only giving me href number not the file attachment..can you please guide me how to resolve this. thank you
DeleteHi!
ReplyDeletevery good example
but i want to read the file from a variable .......now to write
"ora:readFile('file:////FILE_NAME.EXTN')"
This correct........
ora:readFile("file///bpws:getVariableData('inputVariable','payload','/client:process/client:attachmentURI')")
Thanks.
DeleteConcatenate the file name with 'file:///' using concat() function and then use that as a variable in ora:readFile() function. It should work.
Hi!
ReplyDeletevery good example
But want to read file location through an variable...
How to read.......?
Hi,
DeleteYou could concat the 'file:///' with your actual file location and pass that as a variable. It should work.
Hi Neeraj,
ReplyDeleteThanks for this post. Could you please upload this example bpel code here?
Hi Neeraj,
ReplyDeleteThanks for the useful post.
Could you please let me know how to send the payload in xml format at the runtime when any fault occurs in bpel flow.
Basically i what to send the input payload. PLease gimme your inputs
Hi,
ReplyDeleteThanks for your post.
I am unable to use ora:readFile() function to get the content data. please help me.
Hi
ReplyDeleteI need to use customize email template.Content of this template has images. how to do that
Thanks
For the help of others, you can reference the image in your HTML template as below and mail server will send the image too in the body.
Deletehttp://www.w3schools.com/html/html_images.asp
Hi:
ReplyDeleteI was successfull in first part i-e., on setting the value of attachment in E-mail activity itself.
But while try to do the second part i-e., sending a attachement from server location i not getting any mails. What i did was
1)mime type is set to pdf/html (as it is a pdf file)
2)placed the below contents under ConstructBody
Code got successfully compiled but didnt get any mails.
Note: I have ignored the base64 step as it throwed some error in my code like empty value is being passed.
Regards,
Bhaskar
Hi Neeraj,
ReplyDeleteActually I do have one scenario..where I have to read a xml file from one server location and send that xml as an attachment.
Could you please send me your Email attachment example.
Please send it on anu2anu@gmail.com
Regards,
Shweta
Hi Neeraj,
ReplyDeleteThanks for the post,it is hard to follow the steps without looking at the complete complete post, can you please attach your .bpel file to this blog or email it to me.
Thanks,
Jai.
Sorry for that. Actually I am not able to upload the BPEL code here. However I can mail you the same. Please drop me an email and I'll do.
DeleteAny thoughts on sending jpeg files in email body from bpel...
ReplyDeleteHi Neeraj,
ReplyDeleteNice post.
My requirement is to send the rejected message file as an email attachment
I have tried passing the values of the file path and file name to ora:read() but it is showing xpath exception.
Regards,
Srijna
These are the values passing in the email payload:
DeleteHere I have created one variable for file path where I am providing absolute path for the rejected messages file location
from expression="string('/d01/oracle/product/10.1.3/BPELTEST/bpel/domains/default/jca/TNVCatFPEDCategoryUpdate/rejectedMessages')"/>
Here I have created another varirable file_name where I am concatenating file:/// and file path and filename along with extension
from expression="concat("file:///",bpws:getVariableData('file_path'),bpws:getVariableData('inputVariable','payload','/ns1:RejectedMessage/@ns1:RejectionId'),".dat")"/>
and finally passing file_name variable in ora:readfile function
expression="ora:readFile(bpws:getVariableData('file_name'))"/>
but getting the error saying that xpath exception:
XPath expression failed to execute.
Error while processing xpath expression, the expression is "ora:readFile(bpws:getVariableData('file_name'))", the reason is /d01/oracle/product/10.1.3/BPELTEST/bpel/domains/default/tmp/.bpel_FTPRejectionHandlerr_1.0_27e488a35296276ae6d9a3c88d6a2fc8.tmp/oracle.xml.parser.v2.XMLNodeList@d53378 (No such file or directory).
Please verify the xpath query. Please check and reply.
Regards,
Srrijna
hi,
ReplyDeleteI am getting the mail but without attachment.
Please mail your code to me on srijna.saxena@gmail.com.
Regards,
Hi Neeraj,
ReplyDeleteYour explanition is quite simple. I was facing the same issue and would like to try this approach unlike using java embedding.Could you kindly mail to my id: mail2mybulk@gmail.com
Hello Neeraj,
ReplyDeleteNice one. I was able to implement the same , only difference is i am not reading physical file. Instead i am using an FTP adapter , read file as an attachment, then decode the content and send a file.
But the only issue i am facing is with pdf and xslx files. I am able to successfully transfer rest of the files.
Any pointer would be helpful.
Hi Neeraj,
ReplyDeletereally a nice example. Can you please send me the code at debdeepmitra.in@gmail.com
Hi Neeraj,
ReplyDeleteI am facing a problem.FTP adapter is reading a file opq format.Then it is converted to base64 with a decoder.Then the same is send as email attachment.
Now this file is having special characters like 'Á'.In the attachment it is converted to '?'.Can you please help me out in this..
Code Snippets
================================================================
multipart/mixed
=====================================================================
Hi Neeraj,
ReplyDeleteYour post is really helpful in resolving one of long pending issue, but still i m struggling with encoding, could you please provide the code snippet oraclefusion4all@gmail.com
Hi Neeraj,
ReplyDeleteNice example. Can you pls post me the code @ nagarur.nitk@gmail.com.
Thanks
Hi
ReplyDeleteI am getting the mail but without attachment. pls can you post me the code @ nagarur.nitk@gmail.com
Thanks
This comment has been removed by the author.
ReplyDeleteHi Neeraj,
ReplyDeleteCould you please send code to hrsh2002@gmail.com
Could you please send code to nagarur.nitk@gmail.com
ReplyDeleteThanks, nice blog, it worked for me.
ReplyDeletecould u please mail the working project to ssoma.soa@gmail.com
ReplyDeleteHi, Thanks for the useful post. Please send me the code to sugumarayyadhurai@gmail.com
ReplyDeleteNeeraj,
ReplyDeleteCan you send the code to arun.arunramesh@gmail.com?
Can you send code to siram.rk@gmail.com
ReplyDeleteHello Neeraj, please email copy of the code to silentevo@gmail.com? Thank you.
ReplyDeleteDear Neeraj, Thank you for the useful post, could you please send the code to gural0112@gmail.com.
ReplyDelete10x.
FYI, with linux you will use readfile as follow:
ReplyDeleteora:readFile('file:////home/oracle/MyImage.gif')
More details about email attachment on SOA suite:
Deletehttp://docs.oracle.com/cd/B31017_01/integrate.1013/b28981/notif.htm#BABDIDCJ
Hi. Thanks for your post.
ReplyDeleteIts a great thing. But it would great if we could have a look at the code.
Could you please send me the email of the BPEL code to jpriadharshini@gmail.com?
Regards,
Priya
hi neeraj,
ReplyDeleteCan you please share the code to kumar.u.s.n@outlook.com. i used the same steps and in my process and i did a simple attachment text/html but i am not getting the mails.
Thanks,
kumar
Hi Neeraj, How are you ? Nice detail but I am facing some minor issue. Is that possible for you to share the code at gohbk2003@gmail.com. Thanks in Advance
ReplyDeleteHey buddy, i would like you help us, we are trying to attach one pdf in Human task, the problem is when it's sended to IOS Devices, the app mail show clip (attach) but we can't see it but when we create a email component and attach a pdf, it can see in the IOS devices, i can see that the email component have MIME 'multipart/mixed' do you have any suggestion?
ReplyDeleteRegards.
This comment has been removed by the author.
ReplyDeleteHi,
ReplyDeleteNice example. I am facing an issue while sending the csv file as Email attachment. I am able to send the email with csv file but file content is not printing in the file.Can you pls post me the code @ hari.mandadapu@gmail.com.
Thnx
Hi Neeraj
ReplyDeleteThanks for providing such a Nice Post. I have one requirement of polling a file and sending the same file as attachment to mail. Can you please let me know whether have u tried that approach and also please provide the Code to my email : prtpkrishna@gmail.com
Thanks
Pratap.
Nice post...
ReplyDeleteHow can I send multiple files as an attachments to a single receiver through Email.
Hi Niraj,
ReplyDeleteIn SOA12c am writing the file "WorkdayEmployee.csv" into one location (Example: /tmp). In the same BPEL process i have to send the generated file as an attachment to my email id. Could you please help me out. I have gone through the the code which you have mentioned. But am not sure where to add that snippet. If possible can you share the code base to my email address santhosh.kumar49@gmail.com and let me know your number to call you if you permits.
Regards,
Santhosh Kumar. K
Hi. can you please send the code at vipaldua@gmail.com
ReplyDeleteH, can you send the source code to pappu229@gmail.com
ReplyDeleteThis comment has been removed by the author.
ReplyDelete