本文介绍了从asp.net页面发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要将它添加到我的电子邮件的身体,我希望它看起来是这样,但它不工作。
游:lotour.text
日期:loddate.text
方:lolnumparty.text
第一个名字:locfname.text
名字:loclname.text
你看我希望他们之后又当我用它不工作< / BR>
这是我的电子邮件正文。
objEmail.Body =有被做了预订rquest&放大器;的Request.QueryString(补偿)及看到更多详情请点击链接+ X
这是我的全code
如果Page.IsValid而ValidateCCNumber(cardnumber.Text)= true,那么
SqlDataSource1.Insert()
暗淡x As中的String
X =http://www.clubabc.com/bookingrequest/confirm.aspx?date=与& HttpUtility.UrlEn code(now.Text)及与& tfname =与& HttpUtility.UrlEn code(p1fname.Text)及与& tlname =与& HttpUtility.UrlEn code(p1lname.Text)及&放大器;可比=&放大器; HttpUtility.UrlEn code(的Request.QueryString(补偿)及&放大器;土地=&放大器; HttpUtility.UrlEn code(land.Text))
昏暗objEmail作为新MAILMESSAGE()
objEmail.To [email protected]
objEmail.From [email protected]
objEmail.Cc = memail.Text
objEmail.Subject =预定的&放大器制成+ p1fname.Text ++ p1lname.Text +;的Request.QueryString(补偿)
objEmail.Body =有被做了预订rquest&放大器;的Request.QueryString(补偿)及看到更多详情请点击链接+ X
SmtpMail的SmtpServer =mail.bc.com
尝试
SmtpMail.Send(objEmail)
抓住EXC由于异常
的Response.Write(发送失败:+ exc.ToString())
结束Try
的Response.Redirect(http://www.clubabc.com/bookingrequest/confirm.aspx?date=+ now.Text +与& tfname =+ p1fname.Text +与& tlname =+ p1lname.Text +&放大器;可比=+的Request.QueryString(补偿)及&放大器;土地=&放大器; HttpUtility.UrlEn code(land.Text))
elseif的ValidateCCNumber(cardnumber.Text)= false,那么
invalidcard.Visible = TRUE
万一
解决方案
我猜你正在寻找(的):
Environment.NewLine
的< BR>
标签将只在HTML邮件工作
更新
这将是一个非常,你怎么可以使用环境。换行
:
进口系统样品类
公共共享的Sub Main()
昏暗的firstName作为字符串=约翰
昏暗的lastName作为字符串=李四
昏暗的城市作为字符串=布鲁克林 Console.WriteLine(第一名称:+ +的firstName + Environment.NewLine姓+的lastName + Environment.NewLine +城市:城市+ + Environment.NewLine)
结束小组
末级
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>
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 = "[email protected]"
objEmail.From = "[email protected]"
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):
Environment.NewLine
The <br>
tag will only work in HTML Emails.
Update
This would be a very simple example, how you could use 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
这篇关于从asp.net页面发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!