欢迎光临
我们一直在努力

在Web上利用System.Web.Mail发送EMail-.NET教程,E-mail专题

建站超值云服务器,限时71元/月

这是个vb.net的例子~

email.aspx

<%@ page language="vb"

autoeventwireup="false"

codebehind="email.aspx.vb"

inherits="asif.sendemail"%>

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">

<html>

<head>

<title>sendemail</title>

<meta name="vs_showgrid" content="true">

<meta content="microsoft visual studio.net 7.0"

name="generator">

<meta content="visual basic 7.0" name="code_language">

<meta content="javascript" name="vs_defaultclientscript">

<meta content="http://schemas.microsoft.com/intellisense/ie5"

name="vs_targetschema">

</head>

<body ms_positioning="gridlayout">

<form id="form1" method="post" runat="server">

<asp:label id=label5 runat="server" width="464px"

font-size="large" font-bold="true" forecolor="blue"

style="z-index: 100; left: 140px; position: absolute;

top: 42px">

sending email from asp.net webpage

</asp:label>

<asp:textbox id=txtfrom runat="server" width="169px"

style="z-index: 101; left: 236px; position: absolute;

top: 104px">

</asp:textbox>

<asp:label id=label1 runat="server" font-bold="true"

font-names="arial" font-size="smaller"

style="z-index: 102; left: 140px; position: absolute;

top: 106px">

from:

</asp:label>

<asp:requiredfieldvalidator id=requiredfieldvalidator1

runat="server" font-size="x-small"

errormessage="*requiredfield" controltovalidate="txtfrom"

style="z-index: 103; left: 413px; position: absolute;

top: 111px">

</asp:requiredfieldvalidator>

<asp:textbox id=txtto runat="server" width="168px"

style="z-index: 104; left: 236px; position: absolute;

top: 137px">

</asp:textbox>

<asp:label id=label2 runat="server" font-bold="true"

font-names="arial" font-size="smaller"

style="z-index: 105; left: 140px; position: absolute;

top: 138px">

to:

</asp:label>

<asp:requiredfieldvalidator id=requiredfieldvalidator4

runat="server" font-size="x-small"

errormessage="*requiredfield" controltovalidate="txtto"

style="z-index: 106; left: 417px; position: absolute;

top: 145px">

</asp:requiredfieldvalidator>

<asp:textbox id=txtsubject runat="server" width="168px"

style="z-index: 107; left: 236px; position: absolute;

top: 171px">

</asp:textbox>

<asp:label id=label4 runat="server" font-bold="true"

font-names="arial" font-size="smaller"

style="z-index: 108; left: 140px; position: absolute;

top: 173px">

subject:

</asp:label>

<asp:requiredfieldvalidator id=requiredfieldvalidator2

runat="server" font-size="x-small"

errormessage="*requiredfield"

controltovalidate="txtsubject" style="z-index: 109;

left: 417px; position: absolute; top: 177px">

</asp:requiredfieldvalidator>

<asp:textbox id=txtmessage runat="server"

textmode="multiline" width="349px" height="188px"

style="z-index: 110; left: 236px; position: absolute;

top: 214px">

</asp:textbox>

<asp:label id=label3 runat="server" font-bold="true"

font-names="arial" font-size="smaller"

style="z-index: 111; left: 140px; position: absolute;

top: 218px">

message:

</asp:label>

<asp:requiredfieldvalidator id=requiredfieldvalidator3

runat="server" font-size="x-small"

errormessage="*requiredfield"

controltovalidate="txtmessage" style="z-index: 112;

left: 591px; position: absolute; top: 222px">

</asp:requiredfieldvalidator>

<asp:button id=cmdsendemail runat="server"

text="send email" width="165px" font-bold="true"

style="z-index: 113; left: 236px; position: absolute;

top: 418px">

</asp:button>

<asp:label id=lblmessage style="z-index: 114; left: 141px;

position: absolute; top: 76px" runat="server"

font-size="small" width="373px" visible="false">

</asp:label>

</form>

</body>

</html>

email.aspx.vb

imports system.web.mail

public class sendemail

private sub cmdsendemail_click(byval sender as system.object, _

byval e as system.eventargs) handles cmdsendemail.click

dim objmail as new mailmessage()

objmail.from = me.txtfrom.text.tostring

objmail.to = me.txtto.text.tostring

objmail.subject = me.txtsubject.text.tostring

objmail.body = me.txtmessage.text.tostring

objmail.bodyformat = mailformat.html

smtpmail.send(objmail)

me.lblmessage.text = "email has been sent"

end sub

end class

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 在Web上利用System.Web.Mail发送EMail-.NET教程,E-mail专题
分享到: 更多 (0)

相关推荐

  • 暂无文章