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

📄 mailme.aspx.cs

📁 天织在线购物网站完整源码及文档 本网站是一套基于Web2.0思想设计、采用asp.net2.0开发的社区门户产品。它同时也是一套Web2.0全面解决方案
💻 CS
字号:
using System;
using System.Data;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
public partial class MailME : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        TextBox2.Focus();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        String servername = "";
        String name = custString(TextBox2.Text.Trim());
        string sReturn = string.Empty;
        MailMessage mailMsg = new MailMessage();
        mailMsg.BodyFormat = MailFormat.Html;
        mailMsg.To = TextBox1.Text; //收件人
        mailMsg.From = TextBox2.Text; //发件人
        mailMsg.Subject = TextBox3.Text;//邮件的标题 
        mailMsg.Body = FreeTextBox1.Text;//邮件的主题
        mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
        mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", name);
        mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", TextBox4.Text.Trim());
        SmtpMail.SmtpServer = DropDownList1.SelectedValue;
        if (DropDownList1.SelectedValue == "smtp.126.com")
        {
            TextBox1.Text = "gdf87521@126.com";
        }
        else
        {
            TextBox1.Text = "gdf87521@163.com";
        }
        try
        {
            SmtpMail.Send(mailMsg);
            // this.Label1.Text = "发送成功";
            Response.Write("<script>alert('发送成功,等待管理员审批你的信息');</script>");
            Response.Write("<script>window.close();</script>");
        }
        catch (Exception err)
        {
            Response.Write("<script>alert('发送失败');</script>");
        }
    }
    public String custString(String id)
    {
        String T_id = id;
        int len = T_id.Length;
        String tmpString = "";
        String okStr = "";
        for (int i = 0; i <= len; i++)
        {
            tmpString = T_id.Substring(i, 1);
            if (tmpString == "@")
            {
                return okStr;
            }
            else
            {
                okStr = okStr + tmpString;
            }
        }
        return okStr;
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DropDownList1.SelectedValue.Trim() == "smtp.126.com")
        {
            TextBox1.Text = "gdf87521@126.com";
        }
        else
        {
            TextBox1.Text = "gdf87521@163.com";
        }
    }
}

⌨️ 快捷键说明

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