Configuring the Job for sending an email with attachment in HTML format - 7.3

Mail

Version
7.3
Language
English
Product
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Data Governance > Third-party systems > Messaging components (Integration) > Mail components
Data Quality and Preparation > Third-party systems > Messaging components (Integration) > Mail components
Design and Development > Third-party systems > Messaging components (Integration) > Mail components
Last publication date
2024-02-21

Before you begin

The following four context variables have been created:
  • SMTPHost: the IP address of the SMTP server used to send emails
  • SMTPPort: the port number of the SMTP server used to send emails
  • SMTPUserName: the username required for connecting to the SMTP server
  • SMTPPassword: the password required for connecting to the SMTP server

Procedure

  1. Double-click the tCreateTemporaryFile component to open its Basic settings view, select the Use default temporary system directory check box and clear the Use prefix check box.
  2. Double-click the tRowGenerator component to open its row generator editor, in the Number of Rows for RowGenerator field, enter the number of rows to be generated, 5 in this example.
  3. Click the [+] button to add two columns:
    • empno of Integer type, using Numeric.sequence(String,int,int) from the Functions list to generate sequence numbers
    • name of String type, using TalendDataGenerator.getFirstName() from the Functions list to generate random first names

    When done, click OK to close the dialog box.

  4. Double-click the tFileOutputDelimited component to open its Basic settings view, in the File Name field, press Ctrl+Space and from the global variable list displayed, select ((String)globalMap.get("tCreateTemporaryFile_1_FILEPATH")).
  5. Double-click the tSendMail component to open its Basic settings view.
  6. Enter the emails of the receiver and the sender in the To and From fields respectively.
  7. In the Message field, enter the HTML body message of the email.
    "<html><body>The file is located at: " + 
    						((String)globalMap.get("tCreateTemporaryFile_1_FILEPATH")) + 
    						". It is attached in the email for reference.</body></html>"
  8. Click the [+] button under the Attachments table to add a row, in the File cell, press Ctrl+Space and from the global variable list displayed, select ((String)globalMap.get("tCreateTemporaryFile_1_FILEPATH")).
  9. In the SMTP host and SMTP port fields, enter the address and the port of the SMTP server used to send emails. In this example, context variables are used to set the value of the two fields.
  10. Select the SSL Support check box to enable the component to open an SSL connection when communicating with the SMTP server.
  11. Select the Need authentication check box, and in the Username and Password fields, enter the username and the password required for connecting to the SMTP server. In this example, context variables are used to set the value of the two fields.
  12. On the Advanced settings view, select HTML from the MIME subtype from the 'text' MIME type drop-down list.