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

📄 emailmanage.aspx.cs

📁 易想商城系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using System.Net.Mail;
using System.Net;
using System.Text;
using Shop.Web.UI;
using YXShop.BLL;
using YXShop.Model;
namespace YXShop.Web.Admin.EmailManage
{
    public partial class EmailManage : System.Web.UI.Page
    {
        YXShop.BLL.MemberRand dataCAa = new YXShop.BLL.MemberRand();
        protected void Page_Load(object sender, EventArgs e)
        {
            BasePage bp = null;
            if(!IsPostBack)
            {
                if (!PowerTree.PowerPass.isPass("013003008", PowerTree.PowerPanel.PowerType.other))
                {
                    bp = new BasePage();
                    bp.PageError("对不起,你没有发送短信息权限!", "../index.aspx");
                }
                YXShop.BLL.UserCommon datab = new YXShop.BLL.UserCommon();
                YXShop.BLL.MailEstablish dataCAmil = new YXShop.BLL.MailEstablish();
                List<YXShop.Model.MailEstablish> datamil = dataCAmil.GetAll();
                TextBox2.Text = datamil[0].Ms_ServerSmtp.ToString();//邮箱地址
                grid();
                string StrId = Request.QueryString["strId"];
                if (StrId != null)
                {
                    string[] id = StrId.Split(',');
                    int ln = id.Length;
                    string str = "";
                    for (int i = 0; i < id.Length; i++)
                    {
                        if (!id[i].Trim().Equals(""))
                        {
                            try
                            {
                                List<YXShop.Model.UserCommon> datam = datab.GetListByColumn("UID", id[i]);
                                if (datam.Count > 0)
                                {
                                    str += datam[0].UserName + ",";
                                }

                            }
                            catch
                            {
                                continue;
                            }
                        }
                    }
                //if (Session["strnmxx"] != null)
                //{
                //if (Session["strnmxx"] != null)
                //{
                    RadioButton3.Checked = true;
                    m = 3;
                    SelectMembers1.UName = str.Substring(0, (str.Length - 1));
                }
                if (Request["hyname"] != null)
                {
                    try
                    {
                        SelectMembers1.UName = Request["hyname"].ToString();
                    }
                    catch
                    { 
                    }
                    RadioButton3.Checked = true;
                    m = 3;
                }
            }
        }
        protected void grid()
        {
            dg1.DataSource = dataCAa.GetAll();
            dg1.DataBind();
        }

        public void sendmail(string server, string username, string password, string toaddr, string titel, string body)//,string path)
        {
            try
            {
                System.Net.Mail.SmtpClient client = new SmtpClient();
                client.Host = server;
                client.UseDefaultCredentials = false;
                string name = username.Substring(0, username.IndexOf("@")); 
                client.Credentials = new System.Net.NetworkCredential(name, password);
                //星号改成自己邮箱的密码
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                System.Net.Mail.MailMessage message = new MailMessage(username, toaddr, titel, body);
                message.BodyEncoding = System.Text.Encoding.Default;               
                  message.IsBodyHtml = true;
                //添加附件
                //if (path != "" || path != null)
                //{
                //    Attachment data = new Attachment(path, System.Net.Mime.MediaTypeNames.Application.Octet);
                //    message.Attachments.Add(data);
                //}
                client.Send(message);
            }
            catch (Exception ex)
            {

            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            YXShop.BLL.MemberInfo dataCAh = new YXShop.BLL.MemberInfo();
            YXShop.BLL.UserCommon ucBll = new YXShop.BLL.UserCommon();
            YXShop.BLL.MailEstablish dataCAmil = new YXShop.BLL.MailEstablish();
            List<YXShop.Model.MailEstablish> datamil = dataCAmil.GetAll();

// 网易免费邮箱:pop.163.comsmtp.163.com

//Gmail:pop.gmail.comsmtp.gmail.com

//QQ邮箱:pop.qq.comsmtp.qq.com

//Tom邮箱:pop.tom.com smtp.tom.com

//新浪:pop.sina.com.cnsmtp.sina.com.cn

//搜狐:pop3.sohu.comsmtp.sohu.com

//126免费邮箱:pop.126.comsmtp.126.com

//亿邮(eYou.com):pop3.eyou.commx.eyou.com

            string ser = datamil[0].Ms_ServerSmtp.ToString();//邮箱地址
            string name = datamil[0].Ms_Email.ToString();//发件人邮箱
            string pwd = "";//发件人邮箱密码
            string toa = "";//收件人油箱
            string tit = txtxxzt.Text.Trim();//信标题
            string bob = FCKeditor1.Value.Trim();//内容


            if (m == 1)
            {
                //List<YXShop.Model.MemberInfo> datah = dataCAh.GetAll();
                //foreach (YXShop.Model.MemberInfo dd in datah)
                //{
                //    string syx = dd.uEMail;
                //    sendmail(ser, name, pwd, syx, tit, bob);
                //}
                List<YXShop.Model.UserCommon> ucList = ucBll.GetAll();
                foreach(YXShop.Model.UserCommon ucModel in ucList)
                {
                    string syx = ucModel.UEmail;
                    sendmail(ser, name, pwd, syx, tit, bob);
                }
                
            }
            if (m == 3)
            {
                string aacs = SelectMembers1.UName.ToString();
                String[] sjrid = aacs.Split(',');
                int con = sjrid.Length;
                string strdm;
                strdm = "";
                string strcg;
                strcg = "";
                for (int i = 0; i < con; i++)
                {
                    string bn = sjrid[i].ToString();

                    List<YXShop.Model.UserCommon> ucList = ucBll.GetListByColumn("UserName", bn);
                    int userId = -1;
                    string userEmail = "";
                    if (ucList.Count > 0)
                    {
                        userId = ucList[0].UID;
                        userEmail = ucList[0].UserName;
                    }
                    //if (dataCAh.Getpd(bn).uUserId.ToString() != "")
                    if(userId>0)
                    {
                        string syx = userEmail; //dataCAh.Getnm(bn).uEMail;
                        sendmail(ser, name, pwd, syx, tit, bob);
                        int j;
                        j = i - 1;
                        string cdm1 = sjrid[i].ToString();
                        string cdm2;
                        if (i > 0)
                        {
                            cdm2 = sjrid[i].ToString();
                        }
                        else
                        {
                            cdm2 = sjrid[i].ToString();
                        }
                        if (i == 0)
                        {
                            strcg = cdm1;
                        }
                        else
                        {
                            if (strcg == "")
                            {
                                strcg = cdm1;
                            }
                            else
                            {
                                strcg = strcg + "," + cdm1;
                            }
                        }
                    }
                    else
                    {
                        int j;
                        j = i - 1;
                        string cdm1 = sjrid[i].ToString();
                        string cdm2;
                        if (i > 0)
                        {
                            cdm2 = sjrid[i].ToString();
                        }
                        else
                        {
                            cdm2 = sjrid[i].ToString();
                        }

                        if (i == 0)
                        {
                            strdm = cdm1;
                        }

⌨️ 快捷键说明

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