'How to embed file content into body of the email using mail command?

I have requirement,where i need to send file content as mail body.can we dot through unix scripting.

Thanks in Advance



Solution 1:[1]

With the data create a html file. And then send that file in email as content.

use an expression to create your file data like this -

v_data= '  <tr>
    <td>'||company ||'</td>
    <td>'|| contact_person|| '</td>
    <td>'|| country ||'</td>
  </tr>'

Use an aggregator to concat all these data into one single row. group by none.

Then use another expression transformation. create a ports like this -

v_head ='
<head></head>
<body>

<b>pls find below data.</b>
<table>
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>'

v_body = Aggregated_v_data

v_tail='</table></body>'

v_output = v_head||v_body ||v_tail

Then use this output and connect to a flat file target.

Then send this flat file sing mailx command/any mail client.

Output should look like this. screenshot

html file should looks like this

<head></head>
<body>

pls find below data.
<br> </br>
<table>
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>Alfreds </td>
    <td>Maria </td>
    <td>Germany</td>
  </tr>
</table>
</body>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1