I am using apex_mail (in Apex 4.1) to send emails with an attachment.
v_mail_id := apex_mail.send(
p_to => 'firstname.lastname@example.org'
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:
I would like to change it to 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.
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.
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:
where v_image_base64 is the base64 encoded jpg image.
From my experiments the inline attachment with a cid reference seems to work best.