Embed HTML table in email

前端 未结 5 2140
攒了一身酷
攒了一身酷 2021-02-14 11:16

Is it possible to send a table (coded in html) as the body of an email so that the recipient is able to view the table (parsed and displayed).

For example, I want to be

相关标签:
5条回答
  • 2021-02-14 12:04

    Some years ago I found that you can insert a table in the email body when using Thunderbird. Since then I have switched to mutt. So, out of curiosity, I created a table in html by using latex2html on a simple latex table. I then opened the mutt editor to create an email and copied and pasted the html code into the mutt editor and closed it to go to the mutt compose menu. Before sending the email, I used Ctrl-t to edit the content type and change it from "text/plain" to "text/html". Upon sending the email and opening it in gmail in a browser, the table appeared exactly as I would have wanted.

    So, in summary, one can paste an html table into the mutt editor (vim, in my case) and just change the content type before sending it.

    0 讨论(0)
  • 2021-02-14 12:07

    You can create the table in HTML, open it up in a browser and copy & paste it into Outlook (based on the extra information you've provided in comments)

    Outlook will make sense of your HTML, and provide in the same format as you pasted it.

    If the client is using a text only e-mail (less likely nowadays - with most smartphones parsing HTML emails) then it will just appear a similar way to:

    Header| Header 2 | Header 3
    Test  | test     |  Test
    Test  | test     |  Test
    Test  | test     |  Test
    

    Without any styling.

    0 讨论(0)
  • 2021-02-14 12:08

    You can send an email with a table inside it containing data. Just make sure you style it as a 'table containing data'. Use this as an example.

    This is if you are building an email.

    <html>
    <table width="600" style="border:1px solid #333">
      <tr>
        <td align="center">head</td>
      </tr>
      <tr>
        <td align="center">
          body 
          <table align="center" width="300" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #ccc;">
            <tr>
              <td> data </td>
              <td> info </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
    </html>
    
    0 讨论(0)
  • 2021-02-14 12:10

    You can not directly use HTML or Body tag when you embedding HTML in c# string as it already going to display inside HTML Page. Below is a simple table format.

            body += "<table align ='center'>"
            
            body += "<tr>"
            body += "<td align = 'right' > Name :  </td>"
            body += "<td >" + Name + "</td>"
            body += "</tr>"
            body += "<tr>"
            body += "<td align = 'right' > Application ID :</td>"
            body += "<td  >" + ApplicationID + "</td>"
            body += "</tr>"
            body += "<tr>"
            body += "<td align = 'right' > Passport No :</td>"
            body += "<td >" + PassportNo + " </td>"
            body += "</tr>"
            body += "<tr>"
            body += "<td align = 'right' > Voucher No. :</td>"
            body += "<td >" + VoucherNo + "</td>"
            body += "</tr>"
            body += "<tr>"
            body += "<td align = 'right' > Date :  </td>"
            body += "<td >" + PDate + "</td>"
            body += "</tr>"
            body += "</table><br>"
           
    

    You can also do styling like below

    Example

    body+="<td style='padding:10px; height:20px; width=200px'>Hello World!</td>"
    
    0 讨论(0)
  • 2021-02-14 12:18

    This will depend on the recipient's email client. Some display in HTML, others only display plain text.

    0 讨论(0)
提交回复
热议问题