Skip to content
Advertisement

Shell Script : Send html formatted email while inside an array

I am trying to send html formatted email via shell script while reading a tab separated text file in array and need some help. I can see there were multiple similar question on forum and I also have multiple working scripts which can send html emails but I am not able to fit that code when I am inside an array.

apart form this I also need to use a variable and later use it but cant fit it inside my code, for example i have below code to extract first name and make the first letter uppercase but not sure how to merge it in my existing code.

JavaScript

below is my main code and data file and is working fine and creates a html formatted email but the problem is when it reads “print substr(a[user], 2) | cmd” it looses all formatting so the email I receive do have html formatting at start but not when it show me the records I need.

Any help will be appreciated .

Here is my data file

JavaScript

Here is my code

JavaScript

Below code is to generate html table

JavaScript

please refer below link for more details. Shell script -How to group test file records based on column value and send email to corresponding receipents.?

Advertisement

Answer

You need an empty line between the email headers and the body; and you need to add HTML formatting to the table in order for it to render correctly. Something like this, perhaps:

JavaScript

I kept this simple to highlight the general structure. You can add more embellished HTML formatting to your heart’s content once you understand how this works.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement