當前位置:開發者網絡 >> 技術教程 >> ASP教程 >> 郵件相關 >> 內容
精彩推薦
分類最新教程
分類熱點教程
    
如何在ASP+中發送郵件
作者:未知
日期:2003-04-15
人氣:
投稿:Andy.m(轉貼)
來源:未知
字體:
收藏:加入瀏覽器收藏
以下正文:
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>

相關文章: