Skip to content Skip to sidebar Skip to footer

Html Table Output Formatting When Sending Email From Microsoft Outlook Using R

I am trying to convert a dataframe into an html table using the htmlTable package and then send an email using Microsoft Outlook as the email client using RDCOMClient package by ap

Solution 1:

I havent done 'r' but the syntax looks logical so I will take a stab at the solution:

body <- paste0("<html><head><style>body{font-family:Arial, "sans-serif";}table{border-left:1px solid #000000;border-top:1px solid #000000;}table td{border-right:1px solid #000000;border-bottom:1px solid #000000;font-size:16px; font-weight:normal;}table th{border-right:1px solid #000000;border-bottom:1px solid #000000;font-size:16px; font-weight:bold;}</style></head><body>", y, "</body></html>")

Basically i have added a few things to your code:

  • head of the html document which contains the style for the HTML document that you will sending out.
  • start and end tag for body.

<style>
    body{font-family:Arial, "sans-serif"}
    table{border-left:1px solid #000000;border-top:1px solid #000000;}
    table td{border-right:1px solid #000000;border-bottom:1px solid #000000;font-size:16px; font-weight:normal;}
    table th{border-right:1px solid #000000;border-bottom:1px solid #000000;font-size:16px; font-weight:bold;}
</style>

From the above CSS you should be able to the border colors and fonts to suit your liking. Once the table is rendered in emails it should show something similar to:

enter image description here

Let me know if that worked for you.

Cheers


Post a Comment for "Html Table Output Formatting When Sending Email From Microsoft Outlook Using R"