【发布时间】:2016-01-21 20:13:38
【问题描述】:
我正在尝试在自动电子邮件正文中强制换行。
我参考了很多例子,比如"Adding multiple lines to body of SMTP email VB.NET"。
我尝试了许多不同的换行方式:
-
StringBuilder.AppendLine
Dim sb As New StringBuilder sb.AppendLine("For security purposes, only the password will be provided within this email.") sb.AppendLine("Thank you and have a wonderful day.") -
System.Environment.NewLine
strbody = strbody & "Thank you and have a wonderful day. " & System.Environment.NewLine strbody = strbody & "Password: " & Dsa.Tables(0).Rows(0).Item(2) & System.Environment.NewLine & System.Environment.NewLine -
vbNewLine
strbody = strbody & "Thank you and have a wonderful day. " & vbNewLine -
vbCrLf
strbody = strbody & "Thank you and have a wonderful day. " & vbCrLf -
Environment.NewLine
strbody = strbody & "Thank you and have a wonderful day. " & Environment.NewLine
以此类推,但每次收到邮件时都没有换行符。
还有其他版本我可以测试吗?
Dim strbody As String
Try
Dim strTo As String
strbody = ""
strbody = strbody & "Thank you for contacting us to gain account access. " & vbNewLine
strbody = strbody & "You requested your password for the Applicaton registration site. " & vbNewLine
strbody = strbody & "For security purposes, only the password will be provided within this email. " & vbNewLine
strbody = strbody & "Thank you and have a wonderful day. " & vbNewLine
strbody = strbody & "Password: " & Dsa.Tables(0).Rows(0).Item(2) & System.Environment.NewLine & vbNewLine & vbNewLine
strbody = strbody & "If you didn't request your password, please notify from@location.com of your concern "
strTo = Dsa.Tables(0).Rows(0).Item(1)
Dim msg As New System.Net.Mail.MailMessage("from@we-location.com", strTo, "Retrive Your Password", strbody)
Dim smtp As New System.Net.Mail.SmtpClient
msg.IsBodyHtml = True
smtp.Host = "mailhost.location.com"
smtp.Send(msg)
Catch ex As Exception
End Try
【问题讨论】:
标签: vb.net email line-breaks