Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Not in KC anymore
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    HTML email from Excel

    Hello all.

    I was referred to this area of the forum due to the html question I had in a <!post=post,722650>post<!/post>

    I'm sending emails using code from Excel and using the html format that includes tables. I have all the Excel portions figured out however there are some very annoying white "borders" around each cell in the table. I've tried cellpadding and collapsing and I'm not getting the results I need. Been working on it for a few days and I'm about to pull my hair out.

    Here is what I have: (the code is pulling from additional cells other than what was shown in the example spreadsheet) And I'm also only posting the html part of the code.

    .HTMLBody = "All Parts Order Confirmation" & "" & _
    "Estimated Arrival Date" & cell.Offset(0, -1) & " (" & cell.Offset(0, 2) & " - " & cell.Offset(0, 3) & ")" & _
    "Customer Name " & cell.Offset(0, 9) & "" & _
    "<Thead><table border=0><tr><td>PartID </td><td> Part Description</td><td> Color" & "</td></tr></Thead>" & _
    "<tbody><tr><td style='border:solid windowtext 0pt; background:#99CCFF'>" & cell.Offset(0, 10) & "<td style='border:solid windowtext 0pt; background:#99CCFF'>" & _
    cell.Offset(0, 11) & "</td><td style='border:solid windowtext 0pt; background:#99CCFF'>" & _
    cell.Offset(0, 7) & "</tr></td>"
    Set cell2 = cell.Offset(1, 0)
    Do While cell2 = cell
    .HTMLBody = .HTMLBody & _
    "<tr><td style='border:solid windowtext 0pt; background:#99CCFF'n>" & cell2.Offset(0, 10) & "</td><td style='border:solid windowtext 0pt; background:#99CCFF'>" & _
    cell2.Offset(0, 11) & "</td><td style='border:solid windowtext 0pt; background:#99CCFF'>" & _
    cell2.Offset(0, 7)
    Set cell2 = cell2.Offset(1, 0)
    Loop
    .HTMLBody = .HTMLBody & "</tr></td></tbody></table>" & "All Parts Order#: " & cell.Offset(0, 6) & "" & _
    "John Doe" & _
    "Parts Specialist" & _
    "All Parts"


    I hope I've edited the above where it makes sense. I've had to remove some of the rows due to sensitive information. The main part I need help on is just the table part. What else do I need to do to get the border around the body of the table without having the white space between the cells? And keeping the header without any border at all?

    Thanks!

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: HTML email from Excel

    <P ID="edit" class=small>(Edited by Jezza on 21-Jul-08 12:46. Change border style)</P>Try:

    <pre>.HTMLBody = "All Parts Order Confirmation" & "" & _
    "Estimated Arrival Date" & cell.Offset(0, -1) & " (" & cell.Offset(0, 2) & " - " & cell.Offset(0, 3) & ")" & _
    "Customer Name " & cell.Offset(0, 9) & "" & _
    "<Thead><table border="0" cellpadding="0" cellspacing="0" >
    <tr><td>PartID </td><td> Part Description</td><td> Color" & "</td></tr>
    </Thead>" & _
    "<tbody><tr><td style='background:#99CCFF'>" & cell.Offset(0, 10) & "<td style='background:#99CCFF'>" & _
    cell.Offset(0, 11) & "</td><td style='background:#99CCFF'>" & _
    cell.Offset(0, 7) & "</tr></td>"
    Set cell2 = cell.Offset(1, 0)
    Do While cell2 = cell
    .HTMLBody = .HTMLBody & _
    "<tr><td style='background:#99CCFF'>" & cell2.Offset(0, 10) & "</td><td style='background:#99CCFF'>" & _
    cell2.Offset(0, 11) & "</td><td style='background:#99CCFF'>" & _
    cell2.Offset(0, 7)
    Set cell2 = cell2.Offset(1, 0)
    Loop
    .HTMLBody = .HTMLBody & "</tr></td></tbody></table>" & "All Parts Order#: " & cell.Offset(0, 6) & "" & _
    "John Doe" & _
    "Parts Specialist" & _
    "All Parts"
    </pre>

    Jerry

  3. #3
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Not in KC anymore
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HTML email from Excel

    Oh whoops...I wasn't clear enough.

    I need to have a thin black border around all the cells in the table other than the header. I was able to get it with the code I posted originally, but there were spaces between each of the cells.

    What you provided did what I asked for...I just didn't ask for the right thing.

  4. #4
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: HTML email from Excel

    OK

    A little more complex but using CSS to create the styling and to change the format of the code slightly. Here I have over written part of your code and made the column headers fit inside <th> tags. This allows me to them use styles to format the table.

    I have placed it in a text file as the code is slightly longer now
    Jerry

  5. #5
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Not in KC anymore
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HTML email from Excel

    Thanks!

    I'm not sure how friendly CSS is with VB, so I'll give this a shot and see what happens.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •