public void SendNewTopicSubscriptionMail(string forumName, string forumTitle, string forumBody, string topicLink)
        {
            var account = new AccountInfo();
            var departmentMapping = DepartmentService.GetDepartmentForumMappings(forumName);
            var result = GetModeratorEmailIds(forumName);

            var employees = ContactsService.GetByDepartmentOrlocation(departmentMapping);

            var departmentMails = employees.Aggregate(string.Empty, (current, subscription) => current + "," + subscription.Email);
            var subscriptionModel = GetAllSubscribedUsers(forumName);

            var mailIds = subscriptionModel.Aggregate(string.Empty, (current, subscription) => current + "," + subscription.EmployeeEmail);
            mailIds = mailIds + "," + departmentMails;
            var distinctWords = new List<string>(mailIds.ToLowerInvariant().Split(',').Distinct());
            
            mailIds = result.Aggregate(
                distinctWords.Where(t => !string.IsNullOrEmpty(t)).Aggregate(string.Empty,
                (current, t) => current + "," + t), 
                (current, moderators) => current.Replace("," + moderators.ToLowerInvariant(), string.Empty));

            var emailHelper = new EmailHelper();
            var paramters = new Dictionary<string, string>
                {
                    {"ForumName", forumName.Trim()},
                    {"TopicName", forumTitle.Trim()},
                    {"TipicLink", topicLink.Trim()},
                    {"ForumBody", forumBody.Trim()},
                    {"CreatedBy", account.GetFullName()},
                    {"Signature", ApplicationConfiguration.EmailSignature}
                };
            if (!string.IsNullOrEmpty(mailIds))
                emailHelper.SendBccMail("", mailIds, "NewTopicSubscription", paramters);
        }
Exemplo n.º 2
0
        private void SendStatusUpdateEmail(ViewModel.UpcomingEvents businessUpdate, string recieverName, bool isCreated, string name)
        {
            //Send email
            //to do take this method out
            var users = ContactsService.GetPhoneBookList().Where(x => x.Email != String.Empty).OrderBy(x => x.AccountId).ToList();

            var recieverEmail =
                users.FirstOrDefault(x => x.Name.ToLower() == recieverName.ToLower()).Email;

            var type = isCreated ? "A new update has been added " : "Existing update has been modified";

            var paramters = new Dictionary<string, string>
                                {
                                    {"CreatedBy",name},
                                   {"ForCreateOrUpdate",type},
                                   {"Title",businessUpdate.Title},
                                   {"StartTime",businessUpdate.EventTime},
                                   {"EventDate",businessUpdate.Date.ToShortDateString()},

                                   {"Location",businessUpdate.Location},
                                   {"Organiser",businessUpdate.Organizers},
                                   {"Venue",businessUpdate.Venue},
                                   {"Duration",businessUpdate.Duration.ToString()},
                                   {"StartDate",businessUpdate.StartDate.ToShortDateString()},
                                   {"EndDate",businessUpdate.EndDate.ToShortDateString()},
                                  {"ModuleName","Event"},
                                  {"ApproverName",businessUpdate.ApproverName},
                                  {"ModuleUrl",ApplicationConfiguration.ApplicationWebUrl+"/Administration/Event"},
                                  {"NotifyUrl",ApplicationConfiguration.ApplicationWebUrl+"/Administration/Notification"},
                                  {"Signature", ApplicationConfiguration.EmailSignature}
                                };

            if (businessUpdate.IsApproved)
            {
                paramters.Add("appUrl", ApplicationConfiguration.ApplicationWebUrl);
            }


            var emailHelper = new EmailHelper();
            emailHelper.SendMail("", recieverEmail,
                !businessUpdate.IsApproved ? "EventCreationMail" : "EventApproverMail", paramters);
        }
       public HttpResponseMessage SendMailForForumSummary()
        {
            try
            {
                ForumSummaryService = new ForumSummaryService();
                var forumsList = ForumSummaryService.GetAllForumSummary().OrderByDescending(a => a.CreatedDate).ToList(); ;
                var forumBody = string.Empty;
                foreach (var forumSummary in forumsList)
                {
                    var path = ApplicationConfiguration.ApplicationWebUrl + "/Forums/CommentList?strId=" + forumSummary.strId + "&LibraryName=" + HttpUtility.UrlEncode(forumSummary.LibraryName.Replace("/", "_")) + "&ParentFolderPath=" + HttpUtility.UrlEncode(forumSummary.ParentFolderPath) + "&topicName=" + HttpUtility.UrlEncode(forumSummary.TopicName) + "";
                    
                    forumBody = forumBody + "<tr><td>" + forumSummary.LibraryName + "&nbsp;<b><a href=" + path + ">" + forumSummary.TopicName + "</a></b></td></tr>";
                    forumBody = forumBody + "<tr><td>Added By <b>" + forumSummary.CreatedBy + "</b> on <b>" + forumSummary.CreatedDate + "</b></td></tr>";
                    if (forumSummary.CommentCount == 1)
                        {
                            forumBody = forumBody + "<tr><td><b>" + forumSummary.CommentCount + "</b> comment added </td></tr><tr><td><hr></td></tr>";
                        }
                        else if (forumSummary.CommentCount > 1)
                        {
                            forumBody = forumBody + "<tr><td><b>" + forumSummary.CommentCount +
                                        "</b> comments added </td></tr><tr><td><hr></td></tr>";
                        }
                        else
                        {
                            forumBody = forumBody + "<tr><td><hr></td></tr>";
                        }

                }
                if (!string.IsNullOrEmpty(forumBody))
                {
                   
                    var emailHelper = new EmailHelper();
                    var paramters = new Dictionary<string, string>
                    {
                        {"ForumSummary", forumBody.Trim()},
                        {"Signature", ApplicationConfiguration.EmailSignature}
                    };

                    emailHelper.SendMail("", ApplicationConfiguration.ForumSummaryDigestMail, "ForumSummary", paramters);
                }
                return new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(Constants.SummaryWeaklyMail) };
                
            }
            catch (Exception ex) { return new HttpResponseMessage(HttpStatusCode.ExpectationFailed) { Content = new StringContent(ex.Message) }; }
        }
        public void SendReplySubscriptionMail(string forumName, string forumTitle, string forumBody, string topicLink)
        {
            var account = new AccountInfo();
            forumBody = forumBody.Substring(0, 8) + " <b> Reply : </b>" + forumBody.Substring(8, forumBody.Length - 8);
            var departmentMapping = DepartmentService.GetDepartmentForumMappings(forumName);

            var employees = ContactsService.GetByDepartmentOrlocation(departmentMapping);

            var departmentMails = employees.Aggregate(string.Empty, (current, subscription) => current + "," + subscription.Email);
            var subscriptionModel = GetAllSubscribedUsers(forumName);

            var mailIds = subscriptionModel.Aggregate(string.Empty, (current, subscription) => current + "," + subscription.EmployeeEmail);
            mailIds = mailIds + "," + departmentMails;
            var distinctWords = new List<string>(mailIds.ToLowerInvariant().Split(',').Distinct());
            mailIds = distinctWords.Where(t => !string.IsNullOrEmpty(t)).Aggregate(string.Empty, (current, t) => current + "," + t);

            var emailHelper = new EmailHelper();
            var paramters = new Dictionary<string, string>
                {
                    {"ForumTitle", forumName + " : " +forumTitle.Trim()},
                    {"ForumBody", forumBody.Trim()},
                    {"PostedBy", account.GetFullName()},
                    {"TipicLink", topicLink.Trim()},
                    {"Signature", ApplicationConfiguration.EmailSignature}
                };
            if (!string.IsNullOrEmpty(mailIds))
                emailHelper.SendBccMail("", mailIds, "CommentsSubscription", paramters);
        }
 public void SubscriptionRequestMail(string forumName, string mailId, bool isSubscription)
 {
     var emailHelper = new EmailHelper();
     var paramters = new Dictionary<string, string>
         {
             {"ForumName", forumName},
             {"Signature", ApplicationConfiguration.EmailSignature}
         };
     if (!string.IsNullOrEmpty(mailId))
         emailHelper.SendMail("", mailId, isSubscription ? "SubscriptionRequest" : "UnSubscribeRequest", paramters);
 }
        public void SendNewTopicMailToModerator(string topicForumPath, string topicTitle, string topicBody, string topicForum, string topicLink)
        {
            var account = new AccountInfo();
            var result = GetModeratorEmailIds(topicForumPath);
            var moderatorEmails = string.Join(",", result);
            var sendMail = new EmailHelper();

            var paramters = new Dictionary<string, string>
                                {
                                    {"TopicTitle", topicTitle.Trim()},
                                    {"TopicBody", topicBody.Trim()},
                                    {"TipicLink", topicLink.Trim()},
                                    {"TopicForum", topicForum },
                                    {"Requestor", account.GetFullName()},
                                    {"Signature", ApplicationConfiguration.EmailSignature}
                                };
            if (!string.IsNullOrEmpty(moderatorEmails))
                sendMail.SendBccMail("", moderatorEmails, "ForumNewTopicRequest", paramters);
        }
        private void SendStatusUpdateEmail(AnnouncementViewModel announcement, string recieverName, bool isCreated, string name)
        {
            //Send email
            //to do take this method out
            var users = ContactsService.GetPhoneBookList().Where(x => x.Email != String.Empty).OrderBy(x => x.AccountId).ToList();

            var recieverEmail =
                users.FirstOrDefault(x => x.Name.ToLower() == recieverName.ToLower()).Email;

            var type = isCreated ? "A new update has been added " : "Existing update has been modified";


            var paramters = new Dictionary<string, string>
            {
                {"CreatedBy",name},
                {"Announcement", announcement.AnnouncementContent},
                {"ForCreateOrUpdate", type},
                {"StartDate", announcement.StartDate.ToShortDateString()},
                {"EndDate", announcement.EndDate.ToShortDateString()},
                {"ModuleName", "Announcement"},
                {"ApproverName", announcement.ApproverName},
                {"ModuleUrl", ApplicationConfiguration.ApplicationWebUrl + "/Administration/Announcement"},
                {"NotifyUrl", ApplicationConfiguration.ApplicationWebUrl + "/Administration/Notification"},
                {"Signature", ApplicationConfiguration.EmailSignature}
            };

            if (announcement.IsApproved)
            {
                paramters.Add("appUrl", ApplicationConfiguration.ApplicationWebUrl);
            }

            var emailHelper = new EmailHelper();
            emailHelper.SendMail("", recieverEmail,
                !announcement.IsApproved ? "AnnouncementCreationMail" : "AnnouncementApproverMail", paramters);
        }