emaila.aspx
来自「用VB实现」· ASPX 代码 · 共 139 行
ASPX
139 行
<%@ Page Language="VB" ContentType="text/html" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>电子邮件高级设定</title>
<style type="text/css">
<!--
.style1 {font-weight: bold}
.style3 {font-size: x-large}
-->
</style>
</head>
<SCRIPT runat="server">
Sub SendMail()
Dim strTo As String = ToBox.Text
Dim strFrom As String = FromBox.Text
Dim strSubject As String = SubjectBox.Text
Dim strBody As String =BodyBox.Text
Dim strCC AS STRING = CCBox.Text
Dim strAttachName as string
Dim objMailMressage As New System.Web.Mail.MailMessage()
Dim objMailAttachment As System.Web.Mail.MailAttachment
objMailMressage.To = strTo
objMailMressage.From = strFrom
objMailMressage.Subject = strSubject
objMailMressage.Body = strBody
objMailMressage.cc = strCC
Select case true
case rdbP1.Checked
objMailMressage.Priority = System.Web.Mail.MailPriority.High
case rdbP2.Checked
objMailMressage.Priority = System.Web.Mail.MailPriority.Low
case rdbP3.Checked
objMailMressage.Priority = System.Web.Mail.MailPriority.Normal
End Select
Select case true
case rdbFHTML.Checked
objMailMressage.BodyFormat =System.Web.Mail.MailFormat.Html
case rdbPTEXT.Checked
objMailMressage.BodyFormat = System.Web.Mail.MailFormat.Text
End Select
strAttachName =fielName.PostedFile.FileName
If Len(strAttachName) > 0 Then
objMailAttachment = New System.Web.Mail.MailAttachment(strAttachName)
objMailMressage.Attachments.Add(objMailAttachment)
End If
System.Web.Mail.SmtpMail.SmtpServer ="127.0.0.1"
System.Web.Mail.SmtpMail.Send(objMailMressage)
Response.Redirect("MailSucess.aspx")
End Sub
Sub btnMail_Click(sender As Object, e As System.EventArgs)
SendMail()
End Sub
</SCRIPT>
<body>
<form enctype="multipart/form-data" runat="server">
<div align="center">
<table width="616" border="0">
<tr>
<td colspan="2"><div align="center" class="style1"><span class="style3">在线发送邮件</span>
<hr>
</div></td>
</tr>
<tr>
<td align="right" ><div align="right"><strong>发件人</strong></div></td>
<td width="513">
<div align="left">
<asp:TextBox ID="FromBox" runat="server" />
</div></td>
</tr>
<tr>
<td height="18" align="right"><strong>收件人</strong></td>
<td><div align="left">
<asp:TextBox ID="ToBox" runat="server" />
</div></td>
</tr>
<tr>
<td align="right"><div align="right"><strong>抄送</strong></div></td>
<td><div align="left">
<asp:TextBox ID="CCBox" runat="server" Columns="50" />
</div></td>
</tr>
<tr>
<td colspan="2" align="right"><hr align="left"></td>
</tr>
<tr>
<td align="right"><div align="right"><strong>主题</strong></div></td>
<td><div align="left">
<asp:TextBox ID="SubjectBox" runat="server" />
</div></td>
</tr>
<tr>
<td align="right" valign="top"><div align="right"><strong>内容</strong></div></td>
<td><div align="left">
<asp:TextBox ID="BodyBox" runat="server" Columns="50" TextMode="MultiLine" Rows="10" />
</div></td>
</tr>
<tr valign="middle">
<td height="17"><div align="right"><strong>优先极</strong></div></td>
<td align="left">
<asp:RadioButton ID="rdbP1" Text="高" TextAlign="right" runat="server" GroupName="GPriority" />
<asp:RadioButton ID="rdbP2" Text="中" TextAlign="right" runat="server" GroupName="GPriority" />
<asp:RadioButton ID="rdbP3" Text="低" TextAlign="right" runat="server" GroupName="GPriority" />
</tr>
<tr valign="middle">
<td height="17"><div align="right">
<div align="right"><strong>文件格式</strong></div></td>
<td align="left" >
<asp:RadioButton ID="rdbFHTML" Text="HTML" TextAlign="right" runat="server" GroupName="GFormat" />
<asp:RadioButton ID="rdbPTEXT" Text='文本' TextAlign="right" runat="server" GroupName="GFormat" />
</td>
</tr>
<tr>
<td height="23"><div align="right"><strong>附件</strong></div></td>
<td align="left" valign="middle"><input name="file" type="file" size="60" id ="fielName" runat ="server"></td>
</tr>
<tr align="center">
<td><div align="center"></div></td>
<td><div align="left"></div>
<div align="left"></div>
<div align="left">
<asp:Button ID="btnMail" runat="server" Text="发送邮件" OnClick="btnMail_Click" />
<asp:Label ID="lblMessage" runat="server" /> </div></td>
</tr>
</table>
</div>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?