Skip to content

bonitasoft-presales/connector-email-reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bonita connector email reader

This connector can read email with attachments.

badge badge

Input parameters

Parameter Description Example Gmail settings

emailProtocol

Protocol

imap, imaps

imaps

emailSSL

use SSL (boolean)

true , false

true

emailFolderName

inbox folder name

Inbox

emailHost

hostname

imap.gmail.com

emailPort

port

993

emailUsername

user name

emailPassword

user password

emailBatchSize

number of fetched emails (Integer)

see Gmail documentation for more information.

Output parameter structure

Result is a list of messages.

[
 {
  "attachments":["DocumentValue":{}],(1)
  "messageNumber":7,
  "sendDate":"2021-03-18T14:24:55Z",(2)
  "receivedDate":"2021-03-18T14:24:55Z",(2)
  "subject":"document request [60112]",
  "name":"Walter Bates",
  "from":"[email protected]",
  "body":"<html><body><p>body</p></body></html>",
  }
]
  1. attachments is a List<DocumentValue>

  2. dates are converted to java.util.Instant

you can add them to a multiple document process data:

import org.bonitasoft.engine.bpm.document.DocumentValue

def docs= []

mail.each { currentMail->
    currentMail.attachments.each {
        DocumentValue docValue = it as DocumentValue
        docs.add(docValue)
    }
}
docs

For contract, convert thme to File

import org.bonitasoft.engine.bpm.document.DocumentValue

def docs= []

mail.each { currentMail->
    currentMail.attachments.each {
        DocumentValue documentValue = it as DocumentValue
        FileInputValue fileInputValue= new FileInputValue(documentValue.fileName ,documentValue.mimeType, documentValue.content)
        docs.add(fileInputValue)
    }
}
docs

Build

To build the connector project, type the following command at the root of the project :

./mvnw clean install

The built archive can be found in here target/[artifact id]-[artifact version].zip after the build.