2 Replies Latest reply on Sep 18, 2013 12:56 PM by InoL

    Change content-disposition in email attachment


      I am using apex_mail (in Apex 4.1) to send emails with an attachment.


      v_mail_id := apex_mail.send(

               p_to  => 'somebody@gmail.com'



      apex_mail.add_attachment( p_mail_id    => v_mail_id

                               ,p_attachment => v_image

                               ,p_filename   => 'signature.jpg'

                               ,p_mime_type  => 'image/jpeg');



      Apex creates this as an attachment:


      Content-Disposition: attachment;


      I would like to change it to inline:


      Content-Disposition: inline;


      so I can reference it in my email body with <img src="cid:signature.jpg"/>. Well... I hope it is going to be shown inline anyway if I change Content-Disposition.

      Currently (with Content-Disposition: attachment;) it works for Outlook, but, for instance, not in Gmail in the browser. Gmail shows the image separately as an attachment.


      Is there a way to change the content-disposition with Apex?

      I know it is possible to do it with utl_mail, but this is currently not installed in our databases. I need to involve our DBA to set this up, and I don't know if he is willing to do that.

        • 1. Re: Change content-disposition in email attachment

          Hi InoL,


          I'm sorry to say, but there is no way to for you to control the Content-Disposition of an attachment added through APEX_MAIL.ADD_ATTACHMENT.  The infrastructure is there in the API to support this, perhaps in a future patch set or APEX version, but I fully realize that this doesn't help you today.





          • 2. Re: Change content-disposition in email attachment

            Hi Joel,


            I thought so. I will put this in the Apex feature request database.




            BTW, for other people it might be interesting to know that there is another option I tried that doesn't work in many situations either. You can put this in the email body:


            <img src="data:image/jpeg;base64,'||v_image_base64||'"/>


            where v_image_base64 is the base64 encoded jpg image.


            From my experiments the inline attachment with a cid reference seems to work best.