📄 emailmanagedg.aspx.cs
字号:
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 YXShop.Common;
using System.Net.Mail;
using System.Net;
using System.Text;
namespace YXShop.Web.Admin.Consumer
{
public partial class EmailManagedg : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request["hydhid"] != null)
{
YXShop.BLL.MemberInfo dataCA = new YXShop.BLL.MemberInfo();
List<YXShop.Model.MemberInfo> data = dataCA.GetListByColumn("UID", Convert.ToInt32(Request["hydhid"]));
YXShop.BLL.UserCommon ucBll = new YXShop.BLL.UserCommon();
List<YXShop.Model.UserCommon> ucList = ucBll.GetListByColumn("UID", Request["hydhid"]);
if (ucList.Count == 1)
{
Label1.Text = ucList[0].UserName;
}
YXShop.BLL.MemberRand dataCAz = new YXShop.BLL.MemberRand();
List<YXShop.Model.MemberRand> data1 = dataCAz.GetzId(Convert.ToInt32(data[0].uGroupId.ToString()));
try
{
Label2.Text = data1[0].Rank_name;
}
catch
{
Label2.Text = "普通会员";
}
Label3.Text = data[0].fSurplusCapital.ToString();
Label4.Text = data[0].fUsableStamps.ToString();
Label5.Text = data[0].fIntegral.ToString();
string dateDiff = "0";
if (Convert.ToDateTime(data[0].PeriodOfValidity) > System.DateTime.Now)
{
TimeSpan ts1 = new TimeSpan(Convert.ToDateTime(data[0].PeriodOfValidity).Ticks);
TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks);
TimeSpan ts = ts1.Subtract(ts2).Duration();
dateDiff = ts.Days.ToString();
}
Label6.Text = dateDiff;
}
}
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();
string userEmail = "";
List<YXShop.Model.UserCommon> ucList = ucBll.GetListByColumn("userName", Label1.Text.Trim());
if (ucList.Count == 1)
{
userEmail = ucList[0].UEmail;
}
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();//内容
string syx = userEmail; //dataCAh.Getnm(Label1.Text.Trim()).uEMail;
sendmail(ser, name, pwd, syx, tit, bob);
}
//protected bool sendTheMail(string smtpserver, string userName, string pwd, string strfrom, string strto, string subj, string bodys)
//{
// SmtpClient _smtpClient = new SmtpClient();
// _smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;//指定电子邮件发送方式
// _smtpClient.Host = smtpserver; ;//指定SMTP服务器
// _smtpClient.Credentials = new System.Net.NetworkCredential(userName, pwd);//用户名和密码
// MailMessage _mailMessage = new MailMessage(strfrom, strto);
// _mailMessage.Subject = subj;//主题
// _mailMessage.Body = bodys;//内容
// _mailMessage.BodyEncoding = System.Text.Encoding.Default;//正文编码
// _mailMessage.IsBodyHtml = true;//设置为HTML格式
// _mailMessage.Priority = MailPriority.High;//优先级
// try
// {
// _smtpClient.Send(_mailMessage);
// return true;
// }
// catch (Exception e)
// {
// return false;
// }
//}
//private bool SendTEmail(string strto, string subj, string bodys)
//{
// string smtpServer = "smtp.163.com";
// string userName = "*****";
// string pwd = "********";
// string strFrom = "*******";
// bool bl = sendTheMail(smtpServer, userName, pwd, strFrom, strto, subj, bodys);
// return bl;
//}
//private void SendEmail(string id)
//{
// string subj = Request.Params["subj"];
// string bodys = Request.Params["bodys"];
// //if (id == "-1")
// //{
// List<YXShop.Model.EmailRss> erList = erBll.GetList("isChecked=1");
// bool bl = true;
// foreach (YXShop.Model.EmailRss erModel in erList)
// {
// bl = SendTEmail(erModel.emailName, subj, bodys);
// if (!bl)
// break;
// }
// //}
// //else
// //{
// // id = id.TrimEnd(',');
// // List<YXShop.Model.EmailRss> erList = erBll.GetList("id in(" + id + ")");
// // bool bl = true;
// // foreach (YXShop.Model.EmailRss erModel in erList)
// // {
// // bl = SendTEmail(erModel.emailName, subj, bodys);
// // if (!bl)
// // break;
// // }
// //}
//}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -