When I execute the query as shown the attachment is always empty. I would expect that the contents of the attachment with name AttachmentFileName
would be in the column Attachment
.
How do I retrieve the blob of the file?
select /*+ join_set(mat, mailmessageid, 5000) */ mat.Attachment xmlfilecontents
, mat.division || '-' || AttachmentFileName filename
from mailmessagesreceived mre
join MailMessageAttachments mat
on mat.mailmessageid = mre.id
and mat.Type in ( 20, 22 ) /* 20: UBL 2.0, 22: Simplerinvoicing 1.0 */
where mre.SenderMailbox = 'Facturen@ExactOnline.nl'
and mre.created >= add_months(trunc(sysdate, -1), -10)
and mat.FileSize > 0