Page 1 of 1

Columns do not line up on emailed reports

Posted: Fri May 27, 2016 11:14 am
by joycerecacho
Hi everybody!

I have an issue.
I am trying to send a report by e-mail through DataStage.

The job creates a file with their columns perfectly aligned.
When I see its structure at the Unix terminal, it is perfect...but when I see it at my Outlook, is it not properly configurated.

Example:
Outlook View

Column1 Column2 Column3 Column4
10 50 10 50
10 1000 10 50
10 50 10 50
10 1000 10 50


I tried with and without delimiters, with all fields, or all fields concatenated in just one...

I filled the empty spaces with ' ' to complete the length of the fields.

The email was sent through shell command at the 'after job routine', as follows:

mail -s "Email Subject" address@domain.com.br < emailBodyFile.csv


PS: if I copy and paste the email content in a notepad, for example, it becomes perfectly aligned.
What is missing?

Thanks in advance guys.

Best regards,

Posted: Fri May 27, 2016 11:25 am
by chulett
Perhaps try using a ".txt" extension rather than ".csv"?

Posted: Fri May 27, 2016 11:27 am
by Teej
This is most likely Outlook's fault. I have seen the same thing where a formatted e-mail in a different mail program (i.e. Notes) does not look properly formatted in Outlook.

Try a different mail program.

-T.J.

Posted: Fri May 27, 2016 11:29 am
by chulett
I'd also be curious what exactly what see it in Outlook means? You mean the preview pane while still inside the Outlook email? Or after double-clicking the attachment so it opens up in another tool? Assuming the former as the latter would open a csv file in Excel... and if changing the extension makes no difference there may be an Outlook setting you need to change so it doesn't use a proportional font for the preview of text files.

Posted: Fri May 27, 2016 12:05 pm
by asorrell
Outlook always defaults to a proportional TrueType font - one where the size of spaces and characters are not fixed-width. This forum also defaults to a proportional font, so "llll" and "MMMM" take up significantly different amount of space on the screen even though both of them are four letters long.

Putty and other similar UNIX terminal session utilities always default to a non-proportional (also called mono-spaced) font where each character is the same width on the screen.

Try hitting "forward" on the email, then select the report and change the font to either Courier New or Lucida Sans Typewriter, which are the only two mono-spaced fonts that come with Outlook / Word.

If the columns magically line up, then that's your problem. There are only two ways to get around it:
1) Use tab characters (ctrl-I) to see if you can get it to line up. This can also be tricky if your fields vary in size significantly.
2) Create it as an HTML file, since that can use style sheet selections to enforce a fixed-width font. This is also not easy to do.

FYI - this is one reason most developers just create reports as a .CSV file that can be opened by Excel!

Posted: Fri May 27, 2016 12:15 pm
by joycerecacho
Teej wrote:This is most likely Outlook's fault. I have seen the same thing where a formatted e-mail in a different mail program (i.e. Notes) does not look properly formatted in Outlook.

Try a different mail program.

-T.J.
No way, it is the tool used at the Company.

Posted: Fri May 27, 2016 12:20 pm
by joycerecacho
chulett wrote:I'd also be curious what exactly what see it in Outlook means? You mean the preview pane while still inside the Outlook email? Or after double-clicking the attachment so it opens up in another tool? Assuming the former as the latter would open a csv file in Excel... and if changing the extension makes no difference there may be an Outlook setting you need to change so it doesn't use a proportional font for the preview of text files.
In both cases it happens, I mean, at the previous view or when I open the email.
Independent on the extension ... csv, txt or, without any ...
It makes no difference at the result.

Actually I have to send some results at the e-mail body and not attached.
There is a big list of receivers, so, it doesnt make sense to ask everybody to change their Outlook configuration. And this is the mail tool here in the company for all employees.

Posted: Tue May 31, 2016 8:06 am
by qt_ky
Outlook does let each user choose a font. It's not the best solution but it works individually.

Go into the Outlook options and look for mail options regarding stationary and fonts. One of the settings is for "composing and reading plain text messages." For that setting, choose a fixed-width font, like Consolas.

Posted: Tue May 31, 2016 10:47 am
by UCDI
You should be able to wrap the output in HTML tags for the font and force it that way. You really only need a little bit of html as all you want to do is format the entire document in a single fixed width font, nothing fancy.
The user can STILL over-ride you by setting their email to only accept plain text emails but there is only so much you can control on your end. If they accept HTML, it will use your font if it is on their system, so if you use a standard one, it will work.

Posted: Tue May 31, 2016 12:01 pm
by UCDI
I haven't done it in a while but maybe something like

mailx -a 'Content-Type: text/html' -s "Subject" to@address <test.html

would work?

---
I am rusty here but I know it can be done if you want to try to force the issue.

Posted: Tue May 31, 2016 12:12 pm
by joycerecacho
mailx: Not a recognized flag: a

Posted: Tue May 31, 2016 12:51 pm
by UCDI
Let me see if I can hack out the solution, might be tomorrow.

Posted: Wed Jun 01, 2016 10:25 am
by UCDI
Edit -- didnt see page 2, I think this is very similar to the above post.

This worked to send an simple html file to myself on our system

cat <<'EOF' - test.html | /usr/sbin/sendmail -t
To: name@place
Subject: hello
Content-Type: text/html

EOF

Posted: Wed Jun 01, 2016 11:37 am
by joycerecacho
Guys,
My solution perfectly worked.

I just had to generate my file with html tags, like:

Code: Select all

<pre>Column1     Column2    Column3</pre>
<pre>Value1      Value2     Value3</pre>
<pre>Value1      Value2     Value3</pre>
... and then call that 'sendmail' command like the link I posted above. I called it from After job sub-routine.

Thank you so much,