public ActionResult EmailSend(string subject, string content, string mailToStr)
        {
            string[]      mailCC      = null;
            string[]      mailTo      = mailToStr.Split(',');
            List <string> attachPaths = new List <string>();

            try
            {
                //准备发送邮件对象
                ISendMail sendMail = new UseNetMail();
                sendMail.CreateHost(new ConfigHost()
                {
                    EnableSsl = false,
                    Username  = ConfigurationSettings.AppSettings["EmailUserName"],
                    Password  = ConfigurationSettings.AppSettings["EmailPassword"],
                });
                sendMail.CreateMultiMail(new ConfigMail()
                {
                    From        = ConfigurationSettings.AppSettings["EmailUserName"],
                    To          = mailTo,
                    CC          = mailCC,
                    Subject     = subject,
                    Body        = content,
                    Attachments = attachPaths.ToArray()
                });

                sendMail.SendMail();
            }
            catch (Exception)
            {
            }
            return(Json(""));
        }
        private void ApplyEmailSend(MyApplyDto apply, string recheckUserId)
        {
            try
            {
                MasterService mstService       = new MasterService();
                UserInfoDto   userinfo_Apply   = mstService.UserInfoSearchByUserId(apply.ApplyUserId).FirstOrDefault();
                UserInfoDto   userinfo_Recheck = mstService.UserInfoSearchByUserId(recheckUserId).FirstOrDefault();
                string[]      mailTo           = null;
                if (userinfo_Recheck == null)
                {
                }
                else
                {
                    mailTo = userinfo_Recheck.Email.Split(',');
                }
                string[] mailCC  = null;
                string   subject = userinfo_Apply.UserName + "的" + apply.ApplyTypeId + "申请";
                string   content = "您好,以下是" + userinfo_Apply.UserName + "的申请,请及时在系统进行处理" + "<br>";
                content += "申请Id:" + apply.ApplyId.ToString() + "<br>";
                content += "申请人:" + userinfo_Apply.UserName + "<br>";
                content += "申请类型:" + apply.ApplyTypeId + "<br>";
                content += "申请理由:" + apply.ApplyReason + "<br>";
                content += "项目全称:" + apply.ProjectName + "<br>";
                content += "项目简称:" + apply.ProjectShortName + "<br>";
                content += "供应商全称:" + apply.SupplierName + "<br>";

                List <string> attachPaths = new List <string>();

                //个人签名 图片形式
                string sign = "";
                if (!string.IsNullOrEmpty(userinfo_Apply.EmailFooter))
                {
                    string emailSignFile = Server.MapPath("~/EmailSign/" + userinfo_Apply.EmailFooter);
                    sign = emailSignFile;
                }
                //准备发送邮件对象
                ISendMail sendMail = new UseNetMail();
                sendMail.CreateHost(new ConfigHost()
                {
                    EnableSsl = false,
                    Username  = userinfo_Apply.Email,
                    Password  = userinfo_Apply.EmailPassword,
                });
                sendMail.CreateMultiMail(new ConfigMail()
                {
                    From        = userinfo_Apply.Email,
                    To          = mailTo,
                    CC          = mailCC,
                    Subject     = subject,
                    Body        = content,
                    Resources   = sign.Split(','),
                    Attachments = attachPaths.ToArray()
                });

                sendMail.SendMail();
            }
            catch (Exception)
            {
            }
        }
        public void EmailSend(string toEmail, string toTitle, string toContent)
        {
            try
            {
                MasterService mstService = new MasterService();
                UserInfoDto   userinfo   = mstService.UserInfoSearchByUserId(UserInfo.UserId).FirstOrDefault();


                //发送邮件
                string[] mailTo = toEmail.Split(',');
                string[] mailCC = new string[] { userinfo.Email };

                string subject = toTitle;
                string content = toContent == null ? "" : toContent.Replace("\n", "<br>");

                List <string> attachPaths = new List <string>();


                //个人签名 图片形式
                string sign = "";
                if (!string.IsNullOrEmpty(UserInfo.EmailFooter))
                {
                    string emailSignFile = Server.MapPath("~/EmailSign/" + UserInfo.EmailFooter);
                    sign = emailSignFile;
                }
                //准备发送邮件对象
                ISendMail sendMail = new UseNetMail();
                sendMail.CreateHost(new ConfigHost()
                {
                    EnableSsl = false,
                    Username  = userinfo.Email,
                    Password  = userinfo.EmailPassword,
                });
                sendMail.CreateMultiMail(new ConfigMail()
                {
                    From        = userinfo.Email,
                    To          = mailTo,
                    CC          = mailCC,
                    Subject     = subject,
                    Body        = content,
                    Resources   = sign.Split(','),
                    Attachments = attachPaths.ToArray()
                });

                sendMail.SendMail();
            }
            catch (Exception)
            {
            }
        }
        public ActionResult SaveEmail(SupplierRequirementEmail email, string constractId, string attachs, string otherAttachs)
        {
            MasterService mstService = new MasterService();
            UserInfoDto   userinfo   = mstService.UserInfoSearchByUserId(UserInfo.UserId).FirstOrDefault();

            // 保存合同发送的信息
            service.ConstractEmailSendSave(constractId, UserInfo.UserId);

            //发送邮件
            string[] mailTo = email.Recipients.Split(',');
            string[] mailCC = new string[] { userinfo.Email };
            if (!string.IsNullOrEmpty(email.CCPerson))
            {
                mailCC = mailCC.Union(email.CCPerson.Split(',')).ToArray();
            }
            string subject = email.Title;
            string content = email.EmailContent == null ? "" : email.EmailContent.Replace("\n", "<br>");

            List <string> attachPaths = new List <string>();

            if (attachs != null)
            {
                foreach (string attach in attachs.Split(';'))
                {
                    attachPaths.Add(Server.MapPath("~/ConstractPdf/" + attach));
                }
            }
            if (otherAttachs != null)
            {
                foreach (string attach in otherAttachs.Split(';'))
                {
                    attachPaths.Add(Server.MapPath(EmailAttachs + attach));
                }
            }

            //个人签名 图片形式
            string sign = "";

            if (!string.IsNullOrEmpty(UserInfo.EmailFooter))
            {
                string emailSignFile = Server.MapPath("~/EmailSign/" + UserInfo.EmailFooter);
                sign = emailSignFile;
            }
            //准备发送邮件对象
            ISendMail sendMail = new UseNetMail();

            sendMail.CreateHost(new ConfigHost()
            {
                EnableSsl = false,
                Username  = userinfo.Email,
                Password  = userinfo.EmailPassword,
            });
            sendMail.CreateMultiMail(new ConfigMail()
            {
                From        = userinfo.Email,
                To          = mailTo,
                CC          = mailCC,
                Subject     = subject,
                Body        = content,
                Resources   = sign.Split(','),
                Attachments = attachPaths.ToArray()
            });

            sendMail.SendMail();

            return(Json(""));
        }
예제 #5
0
        public ActionResult SaveEmail(SupplierRequirementEmail email, int SettlementId, string attachs, string otherAttachs)
        {
            MasterService mstService = new MasterService();
            UserInfoDto   userinfo   = mstService.UserInfoSearchByUserId(UserInfo.UserId).FirstOrDefault();

            var findOne = db.SettlementMst.Find(SettlementId);

            if (findOne != null)
            {
                findOne.EmailSendDateTime = DateTime.Now;
                findOne.EmailSendUser     = UserInfo.UserId;
            }
            db.SaveChanges();
            try
            {
                //发送邮件
                string[] mailTo = email.Recipients.Split(',');
                string[] mailCC = new string[] { userinfo.Email };
                if (!string.IsNullOrEmpty(email.CCPerson))
                {
                    mailCC = mailCC.Union(email.CCPerson.Split(',')).ToArray();
                }
                string subject = email.Title;
                string content = email.EmailContent == null ? "" : email.EmailContent.Replace("\n", "<br>");

                List <string> attachPaths = new List <string>();
                if (attachs != null)
                {
                    foreach (string attach in attachs.Split(';'))
                    {
                        attachPaths.Add(Server.MapPath("~/Export/Settlement/" + attach));
                    }
                    if (otherAttachs != null)
                    {
                        foreach (string attach in otherAttachs.Split(';'))
                        {
                            attachPaths.Add(Server.MapPath(EmailAttachs + attach));
                        }
                    }
                }

                //个人签名 图片形式
                string sign = "";
                if (!string.IsNullOrEmpty(UserInfo.EmailFooter))
                {
                    string emailSignFile = Server.MapPath("~/EmailSign/" + UserInfo.EmailFooter);
                    sign = emailSignFile;
                }
                //准备发送邮件对象
                ISendMail sendMail = new UseNetMail();
                sendMail.CreateHost(new ConfigHost()
                {
                    EnableSsl = false,
                    Username  = userinfo.Email,
                    Password  = userinfo.EmailPassword,
                });
                sendMail.CreateMultiMail(new ConfigMail()
                {
                    From        = userinfo.Email,
                    To          = mailTo,
                    CC          = mailCC,
                    Subject     = subject,
                    Body        = content,
                    Resources   = sign.Split(','),
                    Attachments = attachPaths.ToArray()
                });

                sendMail.SendMail();
            }
            catch (Exception)
            {
            }

            // 发完邮件之后保存供应商评分提醒
            try
            {
                MasterService master = new MasterService();
                master.RemindCancelSave("供应商评分填写提醒", findOne.ProjectId.ToString() + "&" + findOne.SupplierId.ToString(), UserInfo.UserId, DateTime.Now.ToString());
            }
            catch (Exception)
            {
            }


            return(Json(""));
        }