It's been a while I implemented it. I would have to dig to find what I did. But luckily the great Lucas Jellema already wrote a nice article that desribes the most important part of the answer on your question: https://technology.amis.nl/2014/08/17/soa-suite-12c-configuring-gmail-as-the-inbound-email-provider-for-ums-imap-ssl/
I would first work this out.
To get the attachment(s) you can use the functions: ora:getAttachmentProperty and ora:getAttachmentContent. This article describes it a bit https://blog.darwin-it.nl/2014/12/oragetattachmentproperty-failed-to.html and a problem that there was in an early version of SOA/BPM Suite. It also describes how SOA/BPM suite stores the attachemtns. In https://blog.darwin-it.nl/2015/01/bpm12c-patch-for-oragetattachmentproper.html I mention the patch that solves the problem. But it should have no problem in the current 12.2.1.x versions.