Skip to main content Skip to complementary content

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

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.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!