excel 为什么vbNewLine不工作?

mrwjdhj3  于 2023-01-03  发布在  其他
关注(0)|答案(2)|浏览(105)
Sub AutoEmail_Consultant2()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim cell As Range
    Dim strbody As String

    Application.DisplayAlerts = False
    Application.ScreenUpdating = False

    Set OutApp = CreateObject("Outlook.Application")

    On Error GoTo cleanup

    For Each cell In Columns("A").Cells.SpecialCells(xlCellTypeConstants)
        If cell.Value Like "?*@?*.?*" Then

            Set OutMail = OutApp.CreateItem(0)
            On Error Resume Next
            With OutMail
                .To = cell.Value
                .Subject = "Payment Reminder"
                .HTMLBody = "Dear " & Cells(cell.Row, "B").Value & "," & vbNewLine & "This email is reminder for payment of " & Cells(cell.Row, "D").Value & " against invoice no: " & Cells(cell.Row, "C").Value & "."
                '.Send
                .Display
            End With
            On Error GoTo 0
            Set OutMail = Nothing
        End If
    Next cell

cleanup:
    Set OutApp = Nothing

    Application.ScreenUpdating = True
End Sub
sd2nnvve

sd2nnvve1#

您必须记住,您正在编写HTML(您正在填充. HTMLObody属性),vbNewLine在HTML中没有任何意义。请改用<br/>

noj0wjuj

noj0wjuj2#

您必须尝试.Body属性而不是.HTMLBody

相关问题