Import emails from a custom source
You can import emails from other data sources into the Pentaho Server using the following procedure. Like any other emails in the Pentaho Repository, the imported emails can be organized in email groups as described in Create an email group.
These instructions create a framework for importing emails from a CSV file.
The pentaho-scheduler-ee-core-10.x.x.jar
file must be included in the project or resolved by using a Maven Project Object Model (POM) to ensure access to AbstractEmailImportService
in the following procedure. If you are using a reference from a POM, it should be marked as <scope>PROVIDED</scope>
, since it can be found in the plugin itself.
The pentaho-scheduler-ee-core-10.x.x.jar
is included with the Scheduler plugin and is located in the server/pentaho-server/pentaho-solutions/system/scheduler-plugin/lib
directory.
Create a class that extends
AbstractEmailImportService
.Example:
public class CsvEmailImportService extends AbstractEmailImportService {}
Create a default constructor. Consider placing a log message in the body to aid in debugging.
Example:
public CsvEmailImportService() {}
Override the
importEmails()
method by using the following example. Replace CSV with a key that represents the name that you plan to use as theemail-source
, which is configured in thesettings.xml
file.String emailSource = EmailGroupsApi.getEmailSource(); if ( emailSource.toUpperCase().startsWith( "CSV" ) && !isAlreadyImported() ) { super.importEmails(); }
Navigate to the
/pentaho-server/pentaho-solutions/system/scheduler-plugin
folder.Open
settings.xml
and change theemail-source
setting to theemail-source
value that you specified when overriding theimportEmails()
method.For this example, you would update the
email-source
setting to"CSV"
.Override the
getEmails()
method by creating a list ofEmailEntity
that is imported into the system.public List<EmailEntity> getEmails() throws EmailImportException
See the example in
com.example.CsvEmailImportService.java
.In the
/pentaho-server/pentaho-solutions/system/scheduler-plugin
folder, add a bean definition for the new class in theplugin.spring.xml
file. Any properties required by the bean can be exposed in theplugin.spring.xml
file.Example:
<bean id="csvEmailImport" class="com.example.CsvEmailImportService" init-method="importEmails" lazy-init="false"> <property name="csvFile" value="/<path>/CSVFile.csv"> </bean>
Last updated
Was this helpful?