单击访问表单上的按钮后,我需要创建一个表格,该表格将是发送给客户的电子邮件正文。我设法使用我需要的标题格式制作表格,但我无法让备用行着色工作。下面是链接到按钮的代码:
'''
`Private Sub TESTbtn_Click()
Set oApp = CreateObject("Outlook.application")
Set oMail = oApp.CreateItem(olMailItem)
oMail.HTMLBody = "<html><head><style> table {font-family: arial, sans-serif;border-collapse: collapse;width: 100%;} td,th{border: 1px solid #dddddd;text-align: left;padding: 8px;} tr: nth-child(even){background-color: #eee;}tr:nth-child(odd) {background-color: #fff; color: white;}th {background-color: black; color: white;}</style></head><body><table><tr><th>Company</th><th>Contact</th><th>Country</th></tr><tr><td>Alfreds Futterkiste</td><td>Maria Anders</td><td>Germany</td></tr><tr><td>Centro comercial Moctezuma</td><td>Francisco Chang</td><td>Mexico</td></tr><tr><td>Ernst Handel</td><td>Roland Mendel</td><td>Austria</td></tr><tr><td>Island Trading</td> <td>Helen Bennett</td><td>UK</td></tr><tr><td>Laughing Bacchus Winecellars</td><td>Yoshi Tannamuri</td><td>Canada</td></tr><tr><td>Magazzini Alimentari Riuniti</td><td>Giovanni Rovelli</td><td>Italy</td></tr></table></body></html>"
' "<html><head><style>table {width:100%;} table, th, td {border: 1px solid black; border-collapse: collapse;} th, td {padding: 15px; text-align: left;} #t01 tr:nth-child(even) {background-color: #eee;} #t01 tr:nth-child(odd) {background-color: #fff;}#t01 th {background-color: black; color: white;}</style></head><body><p>Dear reader,</p><p>Please find below information on the letter.</p>" & "<p>Any queries please let us know</p><p>Regards</p><TABLE id="t01"><TR><TD>Rating:</TD><TD>1</TD></TR><TR><TD>BIN:</TD><TD>1234567</TD></TR><TR><TD>Company name:</TD><TD>Something Ltd.</TD></TR><TR><TD>Status:<TD>New</TD></TABLE> "
oMail.Subject = "Status on case with BIN nr: "
oMail.To = "testemail@gmail.com"
oMail.BodyFormat = 2
oMail.Display
Set oMail = Nothing
Set oApp = Nothing
End Sub`
以下是代码的当前结果:
我错过了什么吗?
谢谢,