Home > Blockchain >  Email Table Style seems not to work for Outlook (send via UTL_Mail)
Email Table Style seems not to work for Outlook (send via UTL_Mail)

Time:01-05

I want to generate an email including some table data and use PLQL to send this to company members. So far I am using some HTML templates and Oracles UTL_mail. I did send emails to a Gmail web interface and to Outlook. As the style seems okay in Gmail, I guess that it is an Outlook issue. I am a complete beginner when it comes to HTML and I am open to any suggestions and workarounds so that the table looks somewhat smooth for Outlook, too.

Below Code will not show any border for Outlook but it does for Gmail and within the W3School-Try-It editor.

 utl_mail.send(sender => '[email protected]'
            , recipients => '[email protected],[email protected]'
            , subject => 'Test Table'
            , message =>
                    '<!doctype html>
                    <html lang="de">
                    <head>
                    <meta charset="utf-8">
                    <title>Oracle Table</title>
                    <style>
                    body {
                    font-family: Arial, Helvetica, sans-serif;
                    padding: 2em;
                    }
                    table.table {
                    width: 80%;
                    }
                    .table th {
                    text-align: left;
                    }
                    table, th, td {
                    border: 1px solid rgba(3,3,3,0.2);
                    border-collapse: collapse;
                    }
                    th.zelle {
                    text-align: left;
                    padding-right: 2rem;
                    }
                    td.zelle {
                    text-align: right;
                    padding-left: 1rem;
                    }
                    img {
                    width: 200px
                    }
                    @media screen and (max-width: 1200px) {
                    body {
                    font-size: 150%;
                    }
                    table {
                    width: 100%;
                    }
                    table.table {
                    width: 60%;
                    font-size: 100%;
                    }
                    tr {
                    display: flex;
                    flex-direction: row;
                    flex-wrap: wrap;
                    margin: 0.5em 0;
                    border: 1px solid rgba(3,3,3,0.2);
                    border-collapse: collapse;
                    }
                    td, th {
                    flex: 1 1 150px;
                    border-collapse: collapse;
                    }
                    th.zelle {
                    text-align: left;
                    padding-right: 1rem;
                    }
                    td.zelle {
                    text-align: right;
                    padding-left: 1rem;
                    }
                    }
                    </style>
                    </head>    <body>        <p> This is a table</p> <br>
                    <table >
                    <tr>
                    <th > Name </th>   <th > Sal </th>   <th > Dep </th>    </tr>  
                    <tr>  <td > Smith </td>   <td > 3k </td>   <td > 12 </td>    </tr>     
                    <tr>  <td > Miller </td>   <td > 3k </td>   <td > 10 </td>    </tr>   
                    <tr>  <td > Johnsen </td>   <td > 5k </td>   <td > 29 </td>    </tr>    
                  </table>     
                  <section>      
                  <p> Best regards, <br>  Peter</p> 
                  </section>   
                  </body>    
                  </html>
                    '
            , mime_type => 'text/HTML; charset= utf-8'
            );
 
 

CodePudding user response:

Debug the code incrementally starting from a minimal representative example and, when that is working, incrementally include extra functionality.

  1. Start without any CSS:

    <!doctype html>
    <html lang="de">
    <head>
      <meta charset="utf-8" />
      <title>Oracle Table</title>
    </head>
    <body>
      <p> This is a table</p><br />
      <table >
        <thead>
          <tr>
            <th > Name </th>   <th > Sal </th>   <th > Dep </th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td > Smith </td>   <td > 3k </td>   <td > 12 </td>
          </tr>     
          <tr>
            <td > Miller </td>   <td > 3k </td>   <td > 10 </td>
          </tr>   
          <tr>
            <td > Johnsen </td>   <td > 5k </td>   <td > 29 </td>
          </tr>
        </tbody>
      </table>     
      <section>      
      <p> Best regards, <br>  Peter</p> 
      </section>
    </body>    
    </html>
    

    Note: I added / to the self-closing tags and added thead and tbody tags; these aren't required (for HTML), just my personal preference.

    Test if that displays as expected.

  2. Add in a single CSS statement:

    <style>
    body {
      font-family: Arial, Helvetica, sans-serif;
      padding: 2em;
    }
    </style>
    

    and test.

  3. Add another CSS statement and test and repeat until you find where it breaks.

  • Related