我想将此添加到我的电子邮件正文中,我希望它看起来像这样,但它不起作用。
Tour: lotour.text
Date: loddate.text
Party: lolnumparty.text
first name: locfname.text
last name: loclname.text
如你所见,我希望他们一个接一个,当我使用</br>
这是我的电子邮件正文。
objEmail.Body = "There was a booking rquest made by " & Request.QueryString("comp") & " to see more details click the link " + x
这是我的完整代码
If Page.IsValid And ValidateCCNumber(cardnumber.Text) = True Then
SqlDataSource1.Insert()
Dim x As String
x = "http://www.clubabc.com/bookingrequest/confirm.aspx?date=" & HttpUtility.UrlEncode(now.Text) & "&tfname=" & HttpUtility.UrlEncode(p1fname.Text) & "&tlname=" & HttpUtility.UrlEncode(p1lname.Text) & "&comp=" & HttpUtility.UrlEncode(Request.QueryString("comp") & "&land=" & HttpUtility.UrlEncode(land.Text))
Dim objEmail As New MailMessage()
objEmail.To = "cnna@BC.com"
objEmail.From = "page@bc.com"
objEmail.Cc = memail.Text
objEmail.Subject = "Booking for " + p1fname.Text + " " + p1lname.Text + " made by " & Request.QueryString("comp")
objEmail.Body = "There was a booking rquest made by " & Request.QueryString("comp") & " to see more details click the link " + x
SmtpMail.SmtpServer = "mail.bc.com"
Try
SmtpMail.Send(objEmail)
Catch exc As Exception
Response.Write("Send failure: " + exc.ToString())
End Try
Response.Redirect("http://www.clubabc.com/bookingrequest/confirm.aspx?date=" + now.Text + "&tfname=" + p1fname.Text + "&tlname=" + p1lname.Text + "&comp=" + Request.QueryString("comp") & "&land=" & HttpUtility.UrlEncode(land.Text))
ElseIf ValidateCCNumber(cardnumber.Text) = False Then
invalidcard.Visible = True
End If
答案 0 :(得分:1)
我猜你正在寻找(MSDN):
Environment.NewLine
<br>
标记仅适用于HTML电子邮件。
<强>更新强>
这将非常simple example,您可以如何使用Environment.NewLine
:
Imports System
Class Sample
Public Shared Sub Main()
Dim firstName As String = "John"
Dim lastName As String = "Doe"
Dim city As String = "Brooklyn"
Console.WriteLine("First name: " + firstName + Environment.NewLine + "Last name: " + lastName + Environment.NewLine + "City: " + city + Environment.NewLine)
End Sub
End Class
答案 1 :(得分:0)
尝试为objEmail变量设置IsHtml属性以获得更多格式化的可能性。
答案 2 :(得分:0)
请勿使用Enviornment.NewLine,而应使用vbCrLf
Environment.NewLine可能只输出Cr或Lf,这可能会导致您的电子邮件:
a)被阻止,因为它不是RFC兼容的
或
b)被标记为垃圾邮件
要在电子邮件中添加新行,请始终使用CrLf。
- 戴夫