[英]sending email in from asp.net page
I want to add this to my email body and i want it to look like this but it doesnt work. 我想将此添加到我的电子邮件正文中,但我希望它看起来像这样,但是它不起作用。
Tour: lotour.text
Date: loddate.text
Party: lolnumparty.text
first name: locfname.text
last name: loclname.text
as you see i want them right after another and it doesnt work when i use a </br>
如您所见,我希望他们接二连三地使用
</br>
this is my email body. 这是我的电子邮件正文。
objEmail.Body = "There was a booking rquest made by " & Request.QueryString("comp") & " to see more details click the link " + x
this is my full code 这是我的完整代码
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
I guess you are searching for ( MSDN ): 我猜您正在搜索( MSDN ):
Environment.NewLine
The <br>
tag will only work in HTML Emails. <br>
标记仅在HTML电子邮件中有效。
Update 更新资料
This would be a very simple example , how you could use Environment.NewLine
: 这将是一个非常简单的示例 ,说明如何使用
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
尝试为objEmail变量设置IsHtml属性,以获得更多的格式设置可能性。
Do not use Enviornment.NewLine, instead use vbCrLf 不要使用Enviornment.NewLine,而要使用vbCrLf
Environment.NewLine may only output Cr or Lf, which may cause your email to either: Environment.NewLine可能仅输出Cr或Lf,这可能会导致您的电子邮件发送至:
a)Be blocked because it's not RFC complient a)被阻止,因为它不符合RFC
or 要么
b)Be marked as spammy b)被标记为垃圾内容
To have new lines in email, always use CrLf. 要在电子邮件中添加新行,请始终使用CrLf。
--Dave -戴夫
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.