Wednesday, September 2, 2015

How to retrieve name of the Email Attachment


Once you have made Attachments to work (UMS Adapter - All about email attachments) in your BPEL process and able to parse them, it may be necessary to retrieve the actual name of the email attachment read. The best way to do that is using out-of-the-box function as given below

The above should return attachment; filename="test.txt"; however, nothing is as simple in this world and to make it true, it is a known BUG:19492062. Luckily, we have a patch 1941333.1 available to apply and get going but it may be time consuming to request a patch, do the impact assessment and get it applied across all environments. Whilst that may be the ideal solution in the long term but to quickly test and retrieve the attachment name you can use property Content-Type as given under.

  • ora:getAttachmentProperty() function on Content-Type returns text/plain; charset=UTF-8; name=test.txt; any additional text;
  • Substring-before() and substring-after() have been done to intelligently extract string after name=
  • emailAttachmentName- is a string type custom variable to store the attachment name

Quite simple till the patch is applied, or do we indeed need the patch now!


  1. ora:getAttachmentProperty('Content-Disposition' gives me inline from legacy application we have been trying.

    However it is giving file name if i fwd mail thru outlook .

    DO u have any pointers to what could be wrong.

    1. Hi Saurav,

      Could you please explain in more detail? What's the expectation and if any errors?

  2. Hi Neeraj,

    I am using the UMS adapter and attaching BPEL as stated here and it is giving the file name properly. But when i tried using the mediator to get the mail attachment to BPEL, the ora:getAttachmentContent and ora:getAttachmentProperty both got errored out. The error is as follows:

    Can you please help on this.

  3. XPath expression failed to execute. An error occurs while processing the XPath expression; the expression is ora:getAttachmentProperty('Content-Type','inputVariable','payload','/ns2:message/ns2:attachment'). The XPath expression failed to execute; the reason was: Cannot load attachment with dbKey: . Check the detailed root cause described in the exception message text and verify that the XPath query is correct.