How to pad information into columns for email

梦想的初衷 提交于 2019-12-11 15:26:49

问题


I am trying send a email from an Oracle database with an SMTP function with Gmail.

The information is selected with a query in the database, so, for each column I set the space with RPAD. I make the message with this structure:

l_mailtext := l_mailtext || CHR(9) || LPAD(L_NUMBER, 6, '0') || CHR(9) ||
                  CHR(9) || CHR(9) || '  ' || I.CONTRACT_REF_NO || CHR(9) ||
                  RPAD(I.SPEI_TRACE_NO, 40, ' ') ||
                  RPAD(I.REMARKS, 30, CHR(32)) || 
                  rpad(I.ACTUAL_AMOUNT, 30, ' ') || 
                  rpad(I.PC_STATUS, 30, ' ') || CHR(10);

Doing the process, I checked the mail sent and the information shows the following; this is via Gmail in Google Chrome.

I copy and paste the same information in a Notepad++ sheet and it shows me the correct layout:

.

So, I need the information looks like Notepad ++ in Gmail. I do not know if there is a ASCIIcharacter for padding information. Because information in "Amount" column disorganizes by Payment concept Column in Gmail message.


回答1:


Your data is padded correctly. You've demonstrated that in NP++. Gmail is displaying your email body in a proportional font, where each character is a different width. I figure, you have two options:

  1. Send the email with a header of Content-type: text/html and make the body HTML (I think you can do this). You could probably wrap <pre> tags around your content, which tells the user agent to render it in a fixed-width font with spacing preserved.

  2. You could send your content in a .txt attachment, which would likely open up in something like Notepad++, where it would be in a fixed-width font. If they have .txt attachments set to open in Wordpad, that won't be true.

Note that this doesn't really have to do with Gmail. This has to do with the mail client your recipient is using and how you are identifying your content. Today, it may be Gmail, tomorrow, they might switch to Outlook or Thunderbird.



来源:https://stackoverflow.com/questions/51266636/how-to-pad-information-into-columns-for-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!