指引网

当前位置: 主页 > 编程开发 > ASP >

如何在ASP+中发送邮件

来源:网络 作者:佚名 点击: 时间:2017-06-22 20:44
[摘要] This article features how to send email from an ASP+ page. Using email from an ASP+ page has many uses (Notify of errors, inform people about a a subject. etc..). This code sample sends a formatted HTML message to the email address entered.
This article features how to send email from an ASP+ page. Using email from an ASP+ page has many uses
(Notify of errors, inform people about a a subject. etc..). This code sample sends a formatted HTML
message to the email address entered. Enjoy this free code!
Here is the code
Page 1. The input form
<html>
<head>
</head>
<body>
<form method="post" name="form1" action="emailhtml2.aspx">
Email Address:<input type="text" name="EmailAddress" size="30" value="youremail@address.com"><br><br>
<input type="submit" value="Send Your Friend an Email using ASP+" name="b1">
</form>
</body>
</html>
Page 2. Sends the email code
<%@ Import Namespace="System.Web.Util" %>
<script language="VB" runat=server>
Sub Page_load(Sender as Object, E as EventArgs)
Dim MyMessage as New MailMessage
MyMessage.To = request.form("EmailAddress")
MyMessage.From = "webmaster"
MyMessage.Subject = "This is message is from ASPFree using ASP+"
Note:We added the BodyFormat to show how to send
formatted HTML remove this line and all the HTML code in
message. The email will send as regular text
MyMessage.BodyFormat = MailFormat.Html
MyMessage.Body = "<html><body><h1>You received this email from <a
href='http://aspfree.com'>ASPFree.com</a> using ASP+!</h1></body></html>"
SmtpMail.Send(MyMessage)
End Sub
</script>
<html>
<head>
<title>Email Formatted HTML message with ASP+</title>
</head>
<body>
You just sent an email message formatted in HTML to:<br>
<h1><% response.write(request.form("EmailAddress")) %></h1>
</body>
</html>

------分隔线----------------------------