Beispiel #1
0
        public void SendMail(string name, string loginId, string password, DateTime expireDate, bool isTest)
        {
            var cmail = new CMail();

            cmail.IsTest = isTest;
            string tempEmail = “[email protected]”;
            string from      = tempEmail;
            string to        = tempEmail;
            string subject   = string.Empty;
            string body      = string.Empty;

            string mailTemplate = "AddWPUserSuccessful";

            subject = string.Format("【重要】Wordpress投稿アカウント発行のお知らせ:{0}様", name);
            using (var reader = new StreamReader(HttpContext.Current.Server.MapPath("~/MailTemplate/" + mailTemplate + ".txt"), System.Text.Encoding.Default))
            {
                body = reader.ReadToEnd();
            }

            body = body.Replace("#社員名#", name)
                   .Replace("#ログインID#", loginId)
                   .Replace("#パスワード#", password)
                   .Replace("#有効期限#", expireDate.ToString("yyyy/MM/dd HH:mm:ss"));

            string[] smtpSettings = ConfigurationManager.AppSettings["Smtp"].Split('/');

            if (!cmail.SendMail(smtpSettings[0], Int32.Parse(smtpSettings[1]), from, to, subject, body, ""))
            {
                //logger.Error(string.Format("■SendMail Error! : {0}", cmail.ErrMsg));
            }
        }