0

I am working on a program where I need to convert a table in HTML and then send it in mail with HTML body. table is coming all fine but the image and border style is not working. When I save the text as HTML file and open it with chrome all styles are working file.

Imports Outlook = Microsoft.Office.Interop.Outlook
Module Module1

    Sub Main()

        ' Create the Outlook application.
        Dim oApp As New Outlook.Application()
        ' Create a new mail item.
        Dim oMsg As Outlook.MailItem = DirectCast(oApp.CreateItem(Outlook.OlItemType.olMailItem), Outlook.MailItem)
        ' Set HTMLBody.
        'add the body of the email
        Dim body_file As String

        body_file = My.Computer.FileSystem.ReadAllText("output_html.txt")
        oMsg.HTMLBody = body_file
        'Subject line
        oMsg.Subject = "Your Subject will go here."
        ' Add a recipient.
        Dim oRecips As Outlook.Recipients = DirectCast(oMsg.Recipients, Outlook.Recipients)
        ' Change the recipient in the next line if necessary.
        Dim oRecip As Outlook.Recipient = DirectCast(oRecips.Add("hkjobs1988@gmail.com"), Outlook.Recipient)
        oRecip.Resolve()
        ' Send.
        oMsg.Send()
        ' Clean up.
        oRecip = Nothing
        oRecips = Nothing
        oMsg = Nothing
        oApp = Nothing
        'end of try block

        'end of catch
    End Sub

End Module

My HTML File output_html.txt content is..

<html>
<head>
<style>
html { 
background: url(bg2.jpg) no-repeat center center fixed; 
background-size: 100% 100%;
}
                        
table, th, td { border: 3px solid white; border-collapse: collapse; }
th, td {padding: 15px;text-align: left;}
#t01 {
width: 100%;    
background-color: #f1f1c1;
}
</style>
</head>
<body>
<table>
<tr><th>Name</th><th>Age</th><th>City</th></tr>
<tr><td>Hitesh</td><td>33</td><td>BSR</td></tr>
<tr><td>Nimesh</td><td>30</td><td>Delhi</td></tr>
<tr><td>Raju</td><td>22</td><td>Mumbai</td></tr>
</table></body></html>
FunThomas
  • 23,043
  • 3
  • 18
  • 34
Aditi Patil
  • 67
  • 1
  • 11

0 Answers0