コード例 #1
0
        public ContentResult sendmail(string email, string title, string content)
        {
            string MessageTo      = email;                                                //收件人邮箱地址
            string MessageSubject = title;                                                //邮件主题
            string MessageBody    = content + new Random().Next(1000, 999999).ToString(); //邮件内容
            //bool c = ecoBio.Wms.Common.MailHelper.Send(MessageTo, MessageSubject, MessageBody);
            bool       c    = true;
            MailHelper mh   = new MailHelper();
            var        img  = Image64Base.GetImageStr("d:\\b.jpg");
            var        html = "<html><head><title>title</title></head><body>这是内容<hr><br><img src=\"data:image/png;base64," + img + "\" /><br><img src=\"http://www.ecobiotech.com.cn/images/logo.gif\" /></body></html>";

            mh.Mail("*****@*****.**", "*****@*****.**", html, "title", "doumiao@ytk");
            //mh.Mail("*****@*****.**", "*****@*****.**", "<html><head><title>title</title></head><body>这是内容<hr><br><img src=\"data:image/png;base64," + img + "\" /></body></html>", "title", "doumiao@ytk");
            mh.Attachments("~\\Content\\my_pdf\\7459.pdf");
            string m = "成功";

            try
            {
                mh.Send();
            }
            catch (Exception ex)
            { m = ex.Message; }
            return(Content(m));
        }
コード例 #2
0
ファイル: ModuleController.cs プロジェクト: gofixiao/dlerp
 public ContentResult sendmail(string email, string title, string content)
 {
     string MessageTo = email; //收件人邮箱地址
     string MessageSubject = title; //邮件主题
     string MessageBody = content + new Random().Next(1000, 999999).ToString(); //邮件内容
     //bool c = ecoBio.Wms.Common.MailHelper.Send(MessageTo, MessageSubject, MessageBody);
     bool c = true;
     MailHelper mh = new MailHelper();
     var img = Image64Base.GetImageStr("d:\\b.jpg");
     var html = "<html><head><title>title</title></head><body>这是内容<hr><br><img src=\"data:image/png;base64," + img + "\" /><br><img src=\"http://www.ecobiotech.com.cn/images/logo.gif\" /></body></html>";
     mh.Mail("*****@*****.**", "*****@*****.**", html, "title", "doumiao@ytk");
     //mh.Mail("*****@*****.**", "*****@*****.**", "<html><head><title>title</title></head><body>这是内容<hr><br><img src=\"data:image/png;base64," + img + "\" /></body></html>", "title", "doumiao@ytk");
        mh.Attachments("~\\Content\\my_pdf\\7459.pdf");
     string m = "成功";
     try
     {
         mh.Send();
     }
     catch (Exception ex)
     { m = ex.Message; }
     return Content(m);
 }
コード例 #3
0
        public ActionResult weeklyserviceemail()
        {
            string name = WebRequest.GetString("name", true);

            #region 查找
            try
            {
                if (Masterpage.CurrUser.email == null || Masterpage.CurrUser.email.ToString() == "")
                {
                    LogHelper.Info(Masterpage.CurrUser.alias, "606013:客户," + Masterpage.CurrUser.client_code + ",邮箱为空,无法发送邮件");
                    return Json(new ReturnValue { message = "邮箱为空,无法发送邮件", status = "error" }, JsonRequestBehavior.AllowGet);
                }
                var filepath = ConfigurationManager.AppSettings["CustomerRes"] + Masterpage.CurrUser.client_code + "/files/servicereport/" + Masterpage.CurrUser.guid.ToString() + "/" + name;
                if (FileHelper.IsFileExist(filepath))
                {
                    #region 发送邮件
                    var send = managementService.GetSendEmailModel();
                    if (send == null)
                    {
                        LogHelper.Info(Masterpage.CurrUser.alias, "606013:客户," + Masterpage.CurrUser.client_code + ",服务报告邮件发送,发送失败未设置系统邮箱");
                        return Json(new ReturnValue { message = "未设置系统邮箱", status = "error" }, JsonRequestBehavior.AllowGet);
                    }
                    MailHelper mh = new MailHelper();
                    var html = "";
                    var title = Masterpage.CurrUser.client_name + "服务报告";
                    mh.Mail(Masterpage.CurrUser.email, send.text, html, title, send.value);
                    mh.Attachments(filepath);

                    try
                    {
                        mh.Send();
                        LogHelper.Info(Masterpage.CurrUser.alias, "606013:客户," + Masterpage.CurrUser.client_code + ",服务报告邮件发送成功" + filepath);
                        return Json(new ReturnValue { message = "", status = "ok" }, JsonRequestBehavior.AllowGet);
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Info(Masterpage.CurrUser.alias, "606013:客户," + Masterpage.CurrUser.client_code + ",服务报告邮件发送,发送失败" + ex.Message);
                        return Json(new ReturnValue { message = ex.Message, status = "error" }, JsonRequestBehavior.AllowGet);
                    }
                    #endregion
                }
                else
                {
                    LogHelper.Info(Masterpage.CurrUser.alias, "606013:客户," + Masterpage.CurrUser.client_code + ",服务报告邮件发送,发送失败,文件不存在" + filepath);
                    return Json(new ReturnValue { message = "文件不存在", status = "error" }, JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception exx)
            {
                LogHelper.Info(Masterpage.CurrUser.alias, "606013:客户," + Masterpage.CurrUser.client_code + ",服务报告邮件发送,发送失败" + exx.Message);
                return Json(new ReturnValue { message = "发送失败", status = "error" }, JsonRequestBehavior.AllowGet);
            }
            #endregion
        }
コード例 #4
0
        public ActionResult servicesemail()
        {
            string guid = WebRequest.GetString("guid", true);
            SiteServiceManagementModel one = new SiteServiceManagementModel();
            #region 查找
            try
            {
                if (Masterpage.CurrUser.email == null || Masterpage.CurrUser.email.ToString() == "")
                {
                    LogHelper.Info(Masterpage.CurrUser.alias, "609014:客户," + Masterpage.CurrUser.client_code + ",服务监管邮件发送失败,guid:" + guid + "用户邮箱为空,无法发送邮件");
                    return Json(new ReturnValue { message = "邮箱为空,无法发送邮件", status = "error" }, JsonRequestBehavior.AllowGet);
                }
                Guid g = Guid.Parse(guid);
                one = managementService.GetSiteServiceManagement(Masterpage.CurrUser.client_code).FirstOrDefault(p => p.service_management_guid == g);
                if (one == null || one.service_content == "")
                {
                    LogHelper.Info(Masterpage.CurrUser.alias, "609014:客户," + Masterpage.CurrUser.client_code + ",服务监管邮件发送失败,guid:" + guid + "未报表未生成");
                    return Json(new ReturnValue { message = "未报表未生成", status = "error" }, JsonRequestBehavior.AllowGet);
                }
                string title = Masterpage.CurrUser.client_name + "[" + one.service_start_time.Value.ToString("yyyyMMdd") + "]现场服务报告";
                //html = html.Replace("$title$", title);
                //html = html.Replace("$number$", one.employee_guid.ToString());
                //html = html.Replace("$employeename$", Masterpage.CurrUser.client_name);
                //html = html.Replace("$starttime$", one.service_start_time.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                //html = html.Replace("$content$", one.service_content);
                //html = html.Replace("$completetime$", one.service_completion_time.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                //html = html.Replace("$checkperson$", one.employee_chinese_name);
                //html = html.Replace("$checktime$", one.service_validate_time.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                //html = html.Replace("$checkcontent$", one.service_validate_comments);

                //createservices(one);
                //string attachment = "~/content/management/" + Masterpage.CurrUser.client_code + "/" + guid + ".pdf";
                string attachment = ConfigurationManager.AppSettings["CustomerRes"] + Masterpage.CurrUser.client_code + "/files/localservice/" + guid + ".pdf";
                #region 发送邮件
                var send = managementService.GetSendEmailModel();
                if (send == null)
                {
                    LogHelper.Info(Masterpage.CurrUser.alias, "609014:客户," + Masterpage.CurrUser.client_code + ",服务监管邮件发送失败,guid:" + guid + "未设置系统邮箱");
                    return Json(new ReturnValue { message = "未设置系统邮箱", status = "error" }, JsonRequestBehavior.AllowGet);
                }
                MailHelper mh = new MailHelper();
                mh.Mail(Masterpage.CurrUser.email, send.text, title, title, send.value);
                mh.Attachments(attachment);

                try
                {
                    mh.Send();
                }
                catch (Exception ex)
                {
                    LogHelper.Info(Masterpage.CurrUser.alias, "609014:客户," + Masterpage.CurrUser.client_code + ",服务监管邮件发送失败,guid:" + guid + ex.Message);
                    return Json(new ReturnValue { message = ex.Message, status = "error" }, JsonRequestBehavior.AllowGet);
                }
                #endregion
                LogHelper.Info(Masterpage.CurrUser.alias, "609014:客户," + Masterpage.CurrUser.client_code + ",服务监管邮件发送成功,guid:" + guid + attachment);
                return Json(new ReturnValue { message = "", status = "ok" }, JsonRequestBehavior.AllowGet);

            }
            catch (Exception ex)
            {
                LogHelper.Info(Masterpage.CurrUser.alias, "609014:客户," + Masterpage.CurrUser.client_code + ",服务监管邮件发送失败,guid:" + guid + ex.Message);
                return Json(new ReturnValue { message = "发送失败" + ex.Message, status = "error" }, JsonRequestBehavior.AllowGet);
            }
            #endregion
        }