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

1 answer

  • answered 2022-05-06 14:51 Koushik Roy

    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='</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>
    
    </body>
    

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum