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.