⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 email.aspx

📁 完整ASP.NET(VB)邮件发送,支持SSL
💻 ASPX
字号:
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Net.Mail" %>

<script language ="vb" runat ="server" >
    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    End Sub
 sub Button1_Click(sender as object , e as EventArgs)
        Dim from As MailAddress
        Dim theto As MailAddress
        from = New MailAddress("admin@zstai.cn", "网站管理员")
        theto = New MailAddress("452359668@qq.com", "名字")
        Dim omail As MailMessage
        omail = New MailMessage(from, theto)

        omail.Subject = TextBox2.Text
        omail.Body = TextBox3.Text

        omail.IsBodyHtml = True
        omail.BodyEncoding = System.Text.Encoding.GetEncoding("GB2312") '邮件采用的编码        
        omail.Priority = MailPriority.High '设置邮件的优先级为高

        '发送邮件服务器
        Dim client As New SmtpClient()
        client.Host = "smtp.live.com"    '指定邮件服务器
        client.EnableSsl = True
        client.Port = 25 '端口要设置成587
        client.Credentials = New NetworkCredential("admin@zstai.cn", "*******") '/指定服务器邮件,及密码

        '发送
        
        client.Send(omail) '发送邮件
        Label1.Text = "恭喜你!邮件发送成功。"


        omail.Dispose() '        //释放资源

        TABLE1.Visible = False
        Table2.Visible = True
end sub
    Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs)
  
        '返回,继续发送
        Response.Redirect(Request.Url.ToString())
        TABLE1.Visible = True
        Table2.Visible = False
    End Sub
        
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table id="TABLE1" runat="server" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td style="width: 393px">
                    收信:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
                    主题:<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
                    内容:<asp:TextBox ID="TextBox3" runat="server" Height="154px" TextMode="MultiLine"
                        Width="336px"></asp:TextBox><br />
                    <asp:Button ID="Button1" runat="server" Text="发送" OnClick="Button1_Click" /></td>
            </tr>
        </table>
    
    </div>
        <table id="Table2" runat="server" border="0" cellpadding="0" cellspacing="0" visible="false">
            <tr>
                <td align="center" style="width: 400px">
                    <asp:Label ID="Label1" runat="server" ForeColor="Red" Text="恭喜您,发表成功!"></asp:Label><br />
                    <asp:Button ID="Button2" runat="server" Text="返回" OnClick="Button2_Click" /></td>
            </tr>
        </table>
    </form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -