0

The requirement is to send a report from an UNIX server. I have a list of data to be shown on the report, let's say from database. I am using sendexchange to send mail. It always sends in plain text format, and the data isn't displayed with proper alignment. I have separated all the columns with fixed width, but I'm still not getting a proper alignment of the data.

This is my setup:

  1. I am using HP-UX
  2. I have only sendexchange, mailx and mail utilities to send mails
  3. I want to show the data not as an attachment but in the content of the mail.
  4. The contents of the mail should be:

CONTENTS - Description of report (Header Probably)

Below that, the details should be in a TABLE

The table consists of a Header which will have column names and Rows which holds the data

Any suggestions?

j0k
  • 22,600
  • 28
  • 79
  • 90
C0de_Hard
  • 72
  • 1
  • 9

1 Answers1

0

There are two issues here. One is the actual content of the email, and the second is how it will be displayed on the recipient's monitor. Unfortunately you can only control the first one.

Here's how I would do that: By creating the contents of the mail using perl instead of a shell script, you can use format to align data however you choose. You can choose to have text centered, right or left adjusted, and numbers adjusted around the decimal point, padding them if necessary.

Do man perlform or perldoc perlform to get full information, if you need help figuring out exactly how to get it to look the way you want, post a question on it!

And back to the intro: The reason you still cannot be guaranteed that the mail will look fine is that the recipient may make changes to their own email client that will affect how the mail is displayed - e.g. even if you do set everything up to align properly with a monospace font, the recipient may choose to view it in Arial, which will mess formatting up.

Jenny D
  • 1,225
  • 9
  • 20
  • I guess, I can align data even through Shell scripts. So is there a way to display the same in some table?? Like Data table??? – C0de_Hard Mar 15 '13 at 13:07
  • Define "table"... You can use `-` and `|` to draw something looking like a table; that's as far as you go while keeping the email plain text. The point of using perl's `format` is to e.g. allow right or center adjustment without you having to count characters. Also, many email clients will show inline HTML as HTML even though the mail isn't marked as such, so that might work, but it's not guaranteed to. – Jenny D Mar 15 '13 at 13:23
  • A suggestion in shell scripting would be easier for me :) – C0de_Hard Mar 15 '13 at 14:04