using System;
using System.Data;
using System.Configuration;
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;

namespace Store.Common
{/// <summary>
    /// SendEmail 的摘要说明
    /// </summary>
    public class SendEmail
    {
        public SendEmail()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }

        private static string IPUrl = "http://192.168.2.127:84"; //IP地址
        //private string HeadImage = "http://192.168.2.127:84/images/head_02.gif"; //标题图片
        //private string ApplyImage = "http://192.168.2.127:84/images/mail_02.gif"; //申请信用证图片


        //private string image1 = ""; //

 

        #region 注册时,发送邮箱进行验证
        public static string SendEmailRegister(string UserName, string myEmail, string RadNum)
        {

            string myTitle = "感谢您注册中国货仓网会员";
            string ipUrl = "http://localhost:84/Reg/Success.aspx";  //保存链接的IP地址
            //string imageUrl = "http://192.168.2.127:84/images/";

            string temp = string.Empty;

            temp = "<html><head>";
            temp += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" />";
            temp += "<title>货仓首页_中国货仓网</title>";
            temp += "<style type=\"text/css\">";
            temp += "</style>";
            temp += "</head>";
            temp += "<body>";
            temp += "<body>";
            temp += "</html>";

 

            try
            {
                jmail.MessageClass MyMail = new jmail.MessageClass();//建立发邮件类
                MyMail.Charset = "GB2312";// 字符集
                MyMail.Encoding = "BASE64";//附件的编码格式
                MyMail.ContentType = "text/html";
                MyMail.ISOEncodeHeaders = false;//信头编码iso-8859-1字符集
                MyMail.Priority = Convert.ToByte(1);//优先级
                MyMail.From = "caiwanguo@163.com";//发送人邮件地址
                MyMail.FromName = "yangfan";//发送人姓名

                MyMail.Subject = myTitle;// 邮件主题
                MyMail.MailServerUserName = "caiwanguo";//身份验证用户名
                MyMail.MailServerPassWord = "1987312";//用户密码

 

                MyMail.AddRecipient(myEmail, "", "");//收件人邮箱
                MyMail.Body = temp;//邮件内容


                if (MyMail.Send("smtp.163.com", false))
                {

                    return "success";

                }
                else
                {
                    return "error";

                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

            }
            return "success";
        }
        #endregion

        #region 注册成功后,发送邮箱
        public static string SendEmailSuccess(string UserName, string myEmail, string UserPwd)
        {
            string IssueProvideInfo = IPUrl + "/Manage/Goods/SelectPage.aspx"; //发布商品供应信息
            string IssueAskInfo = IPUrl + "/Manage/Goods/SelectPage.aspx"; ; //发布商品求购信息
            string CompanyInfo = IPUrl + "/Manage/Goods/MemberBaseInfo.aspx";//发布公司介绍
            string SearchProvideInfo = "#"; //查看供应信息
            //string Forum = "#"; //进入商业论坛

            string myTitle = "感谢您注册中国货仓网会员";

 

            string temp = string.Empty;

            temp += "<html>";
            temp += "<head>";
            temp += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" />";
            temp += "<title>货仓首页_中国货仓网</title>";
            temp += "<style type=\"text/css\">";
            temp += "</style>";
            temp += "</head>";
            temp += "<body>";
            temp += "</body>";
            temp += "</html>";
            temp += "";


            try
            {
                jmail.MessageClass MyMail = new jmail.MessageClass();//建立发邮件类
                MyMail.Charset = "GB2312";// 字符集
                MyMail.Encoding = "BASE64";//附件的编码格式
                MyMail.ContentType = "text/html";
                MyMail.ISOEncodeHeaders = false;//信头编码iso-8859-1字符集
                MyMail.Priority = Convert.ToByte(1);//优先级
                MyMail.From = "caiwanguo@163.com";//发送人邮件地址
                MyMail.FromName = "yangfan";//发送人姓名

                MyMail.Subject = myTitle;// 邮件主题
                MyMail.MailServerUserName = "caiwanguo";//身份验证用户名
                MyMail.MailServerPassWord = "1987312";//用户密码

 

                MyMail.AddRecipient(myEmail, "", "");//收件人邮箱
                MyMail.Body = temp;//邮件内容


                if (MyMail.Send("smtp.163.com", false))
                {

                    return "success";

                }
                else
                {
                    return "error";

                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

            }
            return "success";
        }
        #endregion

        #region 发送邮箱,进行修改密码
        public static string SendEmailUpdatePwd(string UserName, string myEmail, string RadNum)
        {

            string myTitle = "感谢您注册中国货仓网会员";

 

            string temp = string.Empty;

            temp = "<html><head>";
            temp += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" />";
            temp += "<title>货仓首页_中国货仓网</title>";
            temp += "<style type=\"text/css\">";
              temp += "</style>";
            temp += "</head>";
            temp += "<body>";
                temp += "<body>";
            temp += "</html>";

       

            try
            {
                jmail.MessageClass MyMail = new jmail.MessageClass();//建立发邮件类
                MyMail.Charset = "GB2312";// 字符集
                MyMail.Encoding = "BASE64";//附件的编码格式
                MyMail.ContentType = "text/html";
                MyMail.ISOEncodeHeaders = false;//信头编码iso-8859-1字符集
                MyMail.Priority = Convert.ToByte(1);//优先级
                MyMail.From = "caiwanguo@163.com";//发送人邮件地址
                MyMail.FromName = "yangfan";//发送人姓名

                MyMail.Subject = myTitle;// 邮件主题
                MyMail.MailServerUserName = "caiwanguo";//身份验证用户名
                MyMail.MailServerPassWord = "1987312";//用户密码

 

                MyMail.AddRecipient(myEmail, "", "");//收件人邮箱
                MyMail.Body = temp;//邮件内容


                if (MyMail.Send("smtp.163.com", false))
                {

                    return "success";

                }
                else
                {
                    return "error";

                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

            }
            return "success";
        }
        #endregion
    }
}