Esempio n. 1
0
        public HttpResponseMessage SendEmail(EmailDTO postData)
        {
            try
            {
                DotNetNuke.Services.Mail.Mail.SendEmail(PortalSettings.Email, postData.To, postData.Subject, postData.Body);

                return Request.CreateResponse(HttpStatusCode.OK, new { Success = true });
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
            }
        }
Esempio n. 2
0
        public HttpResponseMessage SendOfflineMessageEmail(EmailDTO postData)
        {
            try
            {
                var agents = DepartmentAgentManager.Instance.GetDepartmentAgents(postData.DepartmentID);
                foreach (var agent in agents)
                {
                    var user = UserController.GetUserById(PortalSettings.PortalId, agent.UserID);
                    if (user != null)
                        Mail.SendEmail(PortalSettings.Email, user.Email, postData.Subject, postData.Body);
                }

                if (agents == null || !agents.Any())
                    Mail.SendEmail(PortalSettings.Email, PortalSettings.Email, postData.Subject, postData.Body);

                return Request.CreateResponse(HttpStatusCode.OK, new { Success = true });
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
            }
        }