如何在Outlook消息中添加一个标题,该标题是边界单元格上方的合并单元格?

时间:2018-02-16 09:56:14

标签: html css excel vba outlook

这是电子邮件正文

With emailpod
    .BodyFormat = 3
    .display
    .To = Sheets("email").Range("H1").Value
    .cc = Sheets("email").Range("H2").Value
    .Subject = Sheets("email").Range("H3").Value & Sheets("email").Range   ("H6")
    .HTMLBody = Sheets("email").Range("H4") & "<br><br>" & Sheets("email").Range("H5") & "<br><br>" & getdata & "<br>" & .HTMLBody & "</body>"

End With

这是CCS

Function getdata() As String
Dim podrow As Range, podcolumn As Range, r As Range, c As Range, header As Range
Dim str As String

Sheets("email").Select
Set podcolumn = Range("N2", Range("N2").End(xlDown))

str = "<table>"
str = str & "<head><style>table, th, td {border: 1px solid black; border-collapse:" & _
    "collapse;} td {text-align:right;} </style></head><body>"

Set header= Range("N1")

For Each r In podcolumn

    str = str & "<tr>"
    Set podrow = Range(r, r.End(xlToRight))

    For Each c In podrow
        str = str & "<td>" & c.Value & "</td>"
    Next c

    str = str & "</tr>"
    If r.Row < Range("a1").End(xlDown).Row Then
        str = str & vbNewLine
    End If
Next r

str = str & "</table>"

getdata = str

End Function

数据在N和O列中,并且它是有界的。第一行(N1:O1)合并为中心。从第二行开始,所有数据都正确对齐。

0 个答案:

没有答案