https://documentation.bonitasoft.com/bonita/2022.1/getting-started/configure-email-connector
When pasting this code into the TO field : apiAccessor.getIdentityAPI().getUserContactData(taskAssigneeId, false).email
and testing it, I get this error:
java.lang.reflect.InvocationTargetException
org.bonitasoft.engine.bpm.connector.ConnectorExecutionException: USERNAME=install | org.bonitasoft.engine.core.connector.exception.SConnectorException: org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: Groovy script throws an exception of type class org.bonitasoft.engine.identity.UserNotFoundException with message = The technical user is not a usable user
Expression : SExpressionImpl [name=to(), content=apiAccessor.getIdentityAPI().getUserContactData(taskAssigneeId, false).email
, returnType=java.lang.String, dependencies=[SExpressionImpl [name=apiAccessor, content=apiAccessor, returnType=org.bonitasoft.engine.api.APIAccessor, dependencies=[], expressionKind=ExpressionKind [interpreter=NONE, type=TYPE_ENGINE_CONSTANT]], SExpressionImpl [name=taskAssigneeId, content=taskAssigneeId, returnType=java.lang.Long, dependencies=[], expressionKind=ExpressionKind [interpreter=NONE, type=TYPE_ENGINE_CONSTANT]]], expressionKind=ExpressionKind [interpreter=GROOVY, type=TYPE_READ_ONLY_SCRIPT]]
I've been able to test it putting a random fake account and verifying it arrives on the fake mail server so something in the script must be wrong.