我尝试了以下代码的多种变体,但我仍然得到相同的结果.我想让最后一行"问题描述:......"出现在一个新行上.
我试过vbCrLf,vbCr和&Environment.NewLine&_这些都没有用.
有没有人有任何建议?
只需注意:其他电子邮件格式正确.此外,如果我在"问题标题"行的末尾添加2个vbCr(s),那么它看起来很正常.
特别是这一点似乎是我身边的一根刺.
结果:
代码:
Dim mail As New MailMessage()
Dim strbody As String
strbody = Nothing
'set the addresses
mail.From = New MailAddress("email.address@server.com")
mail.[To].Add(Email_Add)
'set the content
mail.Subject = Issue_Num & " Issue has been created."
strbody = "Your issue has been created." & vbCr & vbCr
strbody += "The Issue Team has received the following issue: " & vbCrLf
strbody += "Issue ID: " & Issue_Num & vbCrLf
strbody += "Issue Title: " & Email_Summary & vbLf
strbody += "Issue Description: " & Description & vbCrLf
mail.Body = strbody
'set the server
Dim smtp As New SmtpClient("mailhost.mailserver.com", 15)
'send the message
smtp.Send(mail)
Run Code Online (Sandbox Code Playgroud)
当我使用以下代码时:
'set the content
mail.Subject = Issue_Num & " Issue has been created."
strbody = "Your issue has been created." & vbCrLf & vbCrLf
strbody += "The Issue Team has received the following issue: " & vbCrLf
strbody += "Issue ID: " & Issue_Num & vbCrLf
strbody += "Issue Title: " & Email_Summary & vbCrLf & vbCrLf
strbody += "Issue Description: " & Description & vbCrLf
Run Code Online (Sandbox Code Playgroud)
我明白了:
将邮件格式设置为HTML,如下所示:
mail.IsBodyHtml = True
Run Code Online (Sandbox Code Playgroud)
然后添加一个html break标记(<br />
),你想要一个换行符.
归档时间: |
|
查看次数: |
4815 次 |
最近记录: |