예제 #1
0
        /// <summary>
        /// 发送邮件
        /// </summary>
        public static void SendEmail(string recieveAddr, string subject, string body)
        {
            try
            {
                MailMessage mail = new MailMessage();
                mail.IsBodyHtml = true;
                mail.From       = new MailAddress(ConfigHelper.SysEmailAddr);
                mail.To.Add(new MailAddress(recieveAddr));
                mail.Subject = subject;
                mail.Body    = body;

                SmtpClient smtp = new SmtpClient();
                smtp.Host        = ConfigHelper.MailHost;
                smtp.Credentials = new NetworkCredential(ConfigHelper.MailUserName, ConfigHelper.MailPassWord);
                smtp.Send(mail);

                mail.Dispose();
            }
            catch (Exception ex)
            {
                Log4Net.Error(ex);
            }
        }
예제 #2
0
        public static String GetStoreDir(int type, ref string virtualPath)
        {
            string   fullPath = string.Empty;
            DateTime n        = DateTime.Now;

            try
            {
                StringBuilder sb = new StringBuilder(ConfigHelper.uploadDir);
                if (type > 0)
                {
                    sb.Append(type.ToString() + "\\");
                }

                sb.Append(n.ToString("yyyy")) //year
                .Append('\\')
                .Append(n.ToString("MM"))     //month
                .Append('\\')
                .Append(n.ToString("dd"))     //day
                .Append('\\')
                .Append(n.ToString("HH"))     //hour
                .Append('\\');

                fullPath = sb.ToString();

                if (!Directory.Exists(fullPath))
                {
                    Directory.CreateDirectory(fullPath);
                }
                virtualPath = fullPath.Replace(ConfigHelper.uploadDir, "").Replace("\\", "/");
            }
            catch (Exception ex)
            {
                Log4Net.Error("StoreDir  " + ex.ToString());
            }

            return(fullPath);
        }