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
2条答案
按热度按时间sd2nnvve1#
您必须记住,您正在编写HTML(您正在填充. HTMLObody属性),vbNewLine在HTML中没有任何意义。请改用
<br/>
。noj0wjuj2#
您必须尝试.Body属性而不是.HTMLBody