我正试图在我的自动电子邮件正文中强制换行。
我引用了许多示例,例如"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
答案 0 :(得分:4)
这里的关键代码是:
public boolean onNavigationItemSelected(MenuItem item) {
drawer.closeDrawers();
switch (item.getItemId()){
case R.id.nav_main:
setContentView(R.layout.content_main);
return true;
case R.id.nav_stickers:
setContentView(R.layout.content_stickers);
return true;
default:
Toast.makeText(getApplicationContext(),"Something went wrong",Toast.LENGTH_SHORT).show();
return true;
}
}
由于您要发送HTML电子邮件,因此必须使用HTML标记来创建换行符。
msg.IsBodyHtml = True
答案 1 :(得分:3)
您使用的是html模板吗?
尝试使用
strbody = strbody & "Thank you and have a wonderful day. <br>"
或\ n
strbody = strbody & "Thank you and have a wonderful day. \n"