示例#1
0
        public ActionResult SendPotentialUserEmail(long id)
        {
            try
            {
                var pu       = _pur.Find(id);
                var template = string.Empty;
                using (_ets)
                {
                    _ets.Configure("..\\GhostHuntAR.Infrastructure\\Email\\Templates");
                    var bindings = _ets.GetTemplateBindings("TestTemplate");
                    bindings["PotentialUserName"]  = pu.Name;
                    bindings["PotentialUserEmail"] = pu.Email;
                    bindings["PotentialUserRole"]  = pu.Role;
                    bindings["UserName"]           = UserHelper.Instance.CurrentUserName;
                    bindings["CurrentDate"]        = DateTime.Now.ToLongDateString();
                    template = _ets.SetTemplateBindings(bindings);
                }

                using (_ses)
                {
                    _ses.Login(new SecurityEncryptionProvider(),
                               Security.SymmetricEncrypt("*****@*****.**".ToBytes()),
                               Security.SymmetricEncrypt("brought$67".ToBytes()));
                    _ses.Send(new SMTPEmailMessage()
                    {
                        Body            = template,
                        FromAddress     = "*****@*****.**",
                        FromDisplayName = UserHelper.Instance.CurrentUserName,
                        Subject         = "Test Email From Email Controller",
                        ToAddress       = pu.Email,
                        ToDisplayName   = pu.Name,
                        IsBodyHtml      = true
                    });
                }

                return(RedirectToAction("PotentialUsers", "Account"));
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                return(new HttpStatusCodeResult(500));
            }
        }