troubleshooting Question

Sending HTML table in email to outlook 2007 client using vb.net

Avatar of wheaten
wheaten asked on
Programming Languages-OtherOutlook.NET Programming
7 Comments1 Solution2147 ViewsLast Modified:
I am using vb.net 2008 and trying to pull data from an access database and output the results to an HTML table in email to clients using Outlook 2007.  I can pull the data and send it just fine, but it will not display in a table in Outlook - so all the data is just jammed together and not readable.  I am not a vb.net expert, so please be as explicit as possible in your answer or use an example.

Here is my sub routine that is creating the HTML and sending the email:


    Private Sub SendStats()

        Dim StatsTable = _
        <html>
            <table style="FONT-SIZE: 12px; FONT-FAMILY: arial" cellSpacing="0" cellPadding="0" width="600" border="1">
                <tr><th>Officer Name</th>
                    <th>Total Calls</th>
                    <th>In Person, In Bank</th>
                    <th>In Person, Outside Bank</th>
                    <th>Phone Call</th>
                    <th>Hot</th>
                    <th>Warm</th>
                    <th>Cold</th>
                    <th>Ice Cold</th>
                    <th>Center of Influence</th>
                    <th>Existing Customer</th>
                    <th>New Prospect</th>
                </tr><%= From Stats In ds.Tables("WeeklyStats").AsEnumerable _
                         Order By Stats("OfficerName") _
                         Select <tr><td><%= Stats("OfficerName") %></td>
                                    <td><%= Stats("Total Calls") %></td>
                                    <td><%= Stats("in person in bank") %></td>
                                    <td><%= Stats("in person outside bank") %></td>
                                    <td><%= Stats("phone call") %></td>
                                    <td><%= Stats("hot") %></td>
                                    <td><%= Stats("warm") %></td>
                                    <td><%= Stats("cold") %></td>
                                    <td><%= Stats("ice cold") %></td>
                                    <td><%= Stats("center of influence") %></td>
                                    <td><%= Stats("existing customer") %></td>
                                    <td><%= Stats("new prospect") %></td>
                                </tr> %>
            </table>
        </html>

        ds.Dispose()
        ds = Nothing


        Dim strMsgBody As String = ""
        Dim smtp As New SmtpClient("mail.domain.com")

        '** Send Email ***
        mail.From = New MailAddress("Stats@domain.com")
        mail.To.Clear()
        mail.To.Add("user@domain.com")

        'send the content
        mail.Subject = "Weekly Prospect Stats"
        mail.IsBodyHtml = True
        mail.Body = StatsTable
        smtp.Send(mail) 'send the message

    End Sub
ASKER CERTIFIED SOLUTION
wheaten

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros