新客网WWW.XKER.COM:致力做中国最专业的网络学院!
学院: 操作系统 - 网络应用 - 服务器 - 网络安全 - 工具软件 - 办公软件 - Web开发 - 数据库 - 网页设计 - 图形图像 - 媒体动画 - 硬件学堂 - 存储频道 - QQ专区
您的位置:首页 > 软件开发 > Web开发 > Asp教程 > 正文:如何在ASP+中发送邮件

如何在ASP+中发送邮件

新客网 XKER.COM 2003-04-15 来源: 收藏本文
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>

收藏】 【评论】 【推荐】 【投稿】 【打印】 【关闭
发表评论
要记得去论坛讨论,点击注册新会员匿名评论
评论内容:不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
阅读排行
随机推荐
实用信息推荐