Exemplo n.º 1
0
        public UploadFileHelper()
        {
            //默认上传路径
            this.Path = System.Web.HttpContext.Current.Server.MapPath("~/");
            //水印图片路径
            this._waterMarkImgPath = Path + "/" + WebConfigManage.GetAppSetting("WaterMarkPath");

            //允许上传的文件类型
            this.AllowFileType = "jpg|gif|bmp|ico|png";
            //传文件的大小,默认2048KB(2MB)
            this.FileSize = 2048;
            //当前时间用作文件名(年,月,日,时,分,秒,3位毫秒)
            this.NewFileName = DateTime.Now.ToString("yMdhhmmssfff");
            //默认不生成小图
            this.SmallPic = false;
            //默认生成小图片最大的长度
            this.MaxWith = 140;
            //默认生成小图片最大的高度度
            this.MaxHeight = 140;
            //默认可以不上传文件
            this.PicNotNull = false;
            string prefix = WebConfigManage.GetAppSetting("SmallPicPrefix");//小图前缀

            //默认图片前缀
            this.SmallPicPrefix = prefix != string.Empty ? prefix : "small_";
            //默认不需要水印
            this.IsWaterMark = false;
            //默认水印类型
            this.WMType = WaterMarkType.WM_IMAGE;
            //水印位置,默认为右下
            this.WMLocation = WaterMarkLocation.WM_BOTTOM_RIGHT;
            //水印文字
            this.WaterMarkText = WebConfigManage.GetAppSetting("WaterMarkText");//水印文字
        }
Exemplo n.º 2
0
        /// <summary>
        /// 发送电子邮件
        /// </summary>
        /// <param name="receiveEmailAddress">接收人电子邮件地址</param>
        /// <param name="emailTitle">电子邮件标题</param>
        /// <param name="emailContent">电子邮件内容</param>
        /// <returns></returns>
        public string Send(string receiveEmailAddress, string emailTitle, string emailContent)
        {
            if (Ping() == "Success")
            {
                string message = string.Empty;//错误报告
                try
                {
                    string sendEmail         = WebConfigManage.GetAppSetting("Email");
                    string SendEmailServer   = WebConfigManage.GetAppSetting("Email_Server");
                    string sendEmailLoginId  = WebConfigManage.GetAppSetting("Email_LoginId");
                    string sendEmailLoginPwd = WebConfigManage.GetAppSetting("Email_LoginPwd");

                    //邮件内容
                    MailMessage mail = new MailMessage(sendEmail, receiveEmailAddress, emailTitle, emailContent);
                    mail.IsBodyHtml = true;
                    mail.Priority   = MailPriority.Normal;
                    mail.Sender     = new MailAddress(sendEmail); //邮件回复地址
                    //发送邮件
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host        = SendEmailServer;
                    smtp.Credentials = new NetworkCredential(sendEmailLoginId, sendEmailLoginPwd); //发邮件的用户名和密码
                    smtp.Send(mail);
                    message = "OK";
                }
                catch (SmtpFailedRecipientsException ex)
                {
                    for (int i = 0; i < ex.InnerExceptions.Length; i++)
                    {
                        SmtpStatusCode status = ex.InnerExceptions[i].StatusCode;
                        if (status == SmtpStatusCode.MailboxBusy ||
                            status == SmtpStatusCode.MailboxUnavailable)
                        {
                            message = "发送失败!可能目标地址正在使用或目标地址无效!";
                        }
                        else
                        {
                            message = "发送失败!邮箱地址为:" + ex.FailedRecipient;
                        }
                    }
                    return(message);
                }
                catch (Exception e)
                {
                    if (message == string.Empty)
                    {
                        message = e.Message;
                    }
                    return(message);
                }
                return(message);
            }
            else
            {
                return("无网络!");
            }
        }
Exemplo n.º 3
0
 public static string GetSmallPicName(string picName)
 {
     return(WebConfigManage.GetAppSetting("WaterMarkPath") + picName);
 }