コード例 #1
0
        public ActionResult Mailto(string to, string toName, string from, string fromName, string subject, string message)
        {
            if (string.IsNullOrEmpty(to))
            {
                throw new ArgumentNullException("to");
            }

            if (string.IsNullOrEmpty(from))
            {
                throw new ArgumentNullException("from");
            }

            if (string.IsNullOrEmpty(toName))
            {
                var toUser = context.Users.Find(u => u.Email.Equals(to, StringComparison.OrdinalIgnoreCase));
                if (toUser != null)
                {
                    toName = (new UserDecorator(toUser, context)).DisplayName;
                }
            }

            Mails.Enqueue(to, subject, "sys_contact", new
            {
                to       = to,
                toName   = toName,
                from     = from,
                fromName = fromName,
                message  = message,
                appUrl   = App.Get().Context.AppUrl.ToString()
            });

            return(new HttpStatusCodeResult(200));
        }
コード例 #2
0
        public void Send(Message message, string from, string to)
        {
            var fromUser = AppContext.Users[from];
            var toUser   = AppContext.Users[to];

            Mails.Enqueue(to, message.Subject, "sys_contacts", new
            {
                to       = toUser.Email,
                toName   = toUser.DisplayName,
                from     = fromUser.Email,
                fromName = fromUser.DisplayName,
                message  = message.Body,
                appUrl   = App.Get().Context.AppUrl.ToString()
            });
        }