电子邮件从excel文本分开的线路

得到的macros运行和刮的名称和邮件地址很好,但我不能让文本发送到不同的行上显示,它显示为一个长长的文本行。 我尝试添加vbline等,但没有任何区别

在Sub mailtoo()

Dim OutApp As Object Dim OutMail As Object Dim cell As Range Application.ScreenUpdating = False Set OutApp = CreateObject("Outlook.Application") On Error GoTo cleanup For Each cell In Columns("b").Cells.SpecialCells(xlCellTypeConstants) If cell.Value Like "?*@?*.?*" And _ LCase(Cells(cell.Row, "c").Value) = "yes" Then Set OutMail = OutApp.CreateItem(0) On Error Resume Next With OutMail .To = cell.Value .Subject = "for Action" .Body = "Dear " & Cells(cell.Row, "A").Value _ & vbNewLine & vbNewLine & _ "line one of text here. " & _ "line two of text here" & _ "line three of text here" & _ "Regards" & _ "your name" .Attachments.Add "C:\demofilename.xlsx" .Send 'Or use Display End With On Error GoTo 0 Set OutMail = Nothing End If Next cell 

清理:

 Set OutApp = Nothing Application.ScreenUpdating = True 

结束小组

无论您想要显示新的文本行,都需要使用该VbNewLinevariables:

  & vbNewLine & vbNewLine & _ "line one of text here. " & vbNewLine & _ "line two of text here" & vbNewLine & _ "line three of text here" & vbNewLine & vbNewLine &_ "Regards" & vbNewLine & _ "your name" 

只要记住,VB行继续字符_不会对string做任何特殊的事情,它只是为了使您的代码本身更具可读性。 如果你删除了行的延续,这对运行时没有任何意义,你的原始代码看起来就像这样执行:

  "line one of text here. " & "line two of text here" & "line three of text here" & "Regards" & "your name"