Пример #1
0
        /// <summary>
        /// Send notification to user when password reset event completed successfully
        /// </summary>
        /// <param name="emailSender"></param>
        /// <param name="context"></param>
        /// <param name="email"></param>
        /// <param name="username"></param>
        /// <param name="link"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static Task SendEmailConfirmationAsync(this IEmailSender emailSender, ApplicationDbContext context, string email, string username, string link, string password)
        {
            if (Settings.Configs.SmtpSettings.enable_email)
            {
                var lst = MailTemplateBLL.Get_Template(context, "USRREG").Result;
                if (lst.Count > 0)
                {
                    if (username.Contains("@"))
                    {
                        username = "******";
                    }
                    string subject = MailProcess.Process2(lst[0].subject, "\\[username\\]", username);
                    subject = MailProcess.Prepare_Email_Signature(subject);

                    string contents = MailProcess.Process2(lst[0].contents, "\\[username\\]", username);
                    contents = MailProcess.Process2(contents, "\\[email\\]", email);
                    contents = MailProcess.Process2(contents, "\\[password\\]", password);
                    string url = "<a href=\"" + link + "\">" + link + "</a>";
                    contents = MailProcess.Process2(contents, "\\[key_url\\]", System.Text.Encodings.Web.HtmlEncoder.Default.Encode(link));

                    // attach signature
                    contents = MailProcess.Prepare_Email_Signature(contents);

                    return(emailSender.SendEmailAsync(email, subject, contents));
                }
            }

            return(Task.CompletedTask);
        }
Пример #2
0
        /// <summary>
        /// Send email through contact us form
        /// </summary>
        /// <param name="emailSender"></param>
        /// <param name="context"></param>
        /// <param name="email"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static Task ContactUsEmailAsync(this IEmailSender emailSender, ApplicationDbContext context, string email, ContactUsViewModel entity)
        {
            if (Settings.Configs.SmtpSettings.enable_email)
            {
                var lst = MailTemplateBLL.Get_Template(context, "CONTACTUS").Result;
                if (lst.Count > 0)
                {
                    string subject = MailProcess.Process2(lst[0].subject, "\\[fullname\\]", entity.SenderName);
                    subject = MailProcess.Prepare_Email_Signature(subject);

                    string contents = MailProcess.Process2(lst[0].contents, "\\[fullname\\]", entity.SenderName);
                    contents = MailProcess.Process2(contents, "\\[phone\\]", entity.PhoneNumber);
                    contents = MailProcess.Process2(contents, "\\[email\\]", entity.EmailAddress);
                    contents = MailProcess.Process2(contents, "\\[message\\]", entity.Body);

                    // attach signature
                    contents = MailProcess.Process2(contents, "\\[website\\]", Settings.Configs.GeneralSettings.website_title);
                    contents = MailProcess.Process2(contents, "\\[website_url\\]", SiteConfiguration.URL);

                    contents = MailProcess.Prepare_Email_Signature(contents);

                    return(emailSender.SendEmailAsync(email, subject, contents));
                }
            }

            return(Task.CompletedTask);
        }
Пример #3
0
    protected void btn_add_Click(object sender, System.EventArgs e)
    {
        string value = txt_content.Value;

        if (txt_key.Text == "")
        {
            Config.ShowMessageV2(msg, "Please enter valid template key", "Error!", 0);
            return;
        }

        if (MailTemplateBLL.Validate_TemplateKey(txt_key.Text))
        {
            Config.ShowMessageV2(msg, "Template key already exist", "Error!", 0);
            return;
        }

        string description = txt_description.Text;

        if (description.Length > 100)
        {
            description = description.Substring(0, 95);
        }
        MailTemplateBLL.Add(txt_key.Text, description, txt_subjecttags.Text, txt_contenttags.Text, txt_subject.Text, value, drp_sorttype.SelectedValue);

        Response.Redirect(Config.GetUrl("adm/sc/mail/Default.aspx?status=added"));
    }
Пример #4
0
        // Send mail to owner of group if user posted new topic in group
        private void GroupMailProcessTemplate(string ownerusername, string title, string username, string emailaddress, string inboxurl, long groupid)
        {
            //if sending mail option enabled
            if (Jugnoon.Settings.Configs.SmtpSettings.enable_email)
            {
                var lst = MailTemplateBLL.Get_Template(_context, "GRPTPAPR").Result;
                if (lst.Count > 0)
                {
                    string subject = MailProcess.Process2(lst[0].subject, "\\[ownerusername\\]", ownerusername);
                    subject = MailProcess.Process2(subject, "\\[username\\]", username);

                    string contents = MailProcess.Process2(lst[0].contents, "\\[ownerusername\\]", ownerusername);
                    contents = MailProcess.Process2(contents, "\\[username\\]", ownerusername);

                    string group_url = Config.GetUrl("group/" + groupid);
                    string url       = "<a href=\"" + group_url + "\">" + group_url + "</a>";

                    contents = MailProcess.Process2(contents, "\\[url\\]", url);
                    contents = MailProcess.Process2(contents, "\\[title\\]", title);
                    contents = MailProcess.Process2(contents, "\\[inboxurl\\]", inboxurl);

                    // attach signature
                    contents = MailProcess.Prepare_Email_Signature(contents);

                    MailProcess.Send_Mail(emailaddress, subject, contents);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Send email reset autorization and processing link to user
        /// </summary>
        /// <param name="emailSender"></param>
        /// <param name="context"></param>
        /// <param name="email"></param>
        /// <param name="username"></param>
        /// <param name="link"></param>
        /// <returns></returns>
        public static Task ChangeEmailResetAsync(this IEmailSender emailSender, ApplicationDbContext context, string email, string username, string link)
        {
            if (Settings.Configs.SmtpSettings.enable_email)
            {
                if (username.Contains("@"))
                {
                    username = "******";
                }
                var lst = MailTemplateBLL.Get_Template(context, "USREMLCREQ").Result;
                if (lst.Count > 0)
                {
                    string subject = MailProcess.Process2(lst[0].subject, "\\[username\\]", username);
                    subject = MailProcess.Prepare_Email_Signature(subject);

                    string contents = MailProcess.Process2(lst[0].contents, "\\[username\\]", username);
                    contents = MailProcess.Process2(contents, "\\[key_url\\]", System.Text.Encodings.Web.HtmlEncoder.Default.Encode(link));
                    contents = MailProcess.Process2(contents, "\\[emailaddress\\]", email);
                    contents = MailProcess.Process2(contents, "\\[domainname\\]", Jugnoon.Settings.Configs.GeneralSettings.website_title);
                    contents = MailProcess.Process2(contents, "\\[unsubscribeurl\\]", UrlConfig.UnsubscribeUrl);

                    // attach signature

                    contents = MailProcess.Prepare_Email_Signature(contents);

                    return(emailSender.SendEmailAsync(email, subject, contents));
                }
            }

            return(Task.CompletedTask);
        }
Пример #6
0
        //********************************************************************************
        // SEND MAIL TO AUTHOR OF TOPIC, ADMIN (MODERATOR) OR ALL USERS WHO POST Comments)
        //*********************************************************************************

        // Mail Logic
        // If user post new topic mail will be sent to user and admin (moderator)
        // If admin approve topic mail will be sent to author (in case of manual review)
        // If normal user post reply, mail will be sent to author and all users who contribute replies and admin
        private void ProcessMail(long tid, long replyid, string username, long groupid, string description, string title)
        {
            try
            {
                string subject = title;
                string content = UtilityBLL.StripHTML(description);
                string url     = Forum_Urls.Prepare_Topic_Url(tid, subject, false);
                if (replyid == 0)
                {
                    // New Topic Posted Mail Will Be Sent To Admin AND Author
                    // send mail to admin
                    var alst = MailTemplateBLL.Get_Template(_context, "FORUMTOPIC").Result;
                    Send_Email(username, "admin", "", subject, content, url, alst);
                    // send mail to author
                    var    tlst                 = MailTemplateBLL.Get_Template(_context, "FORUMTA").Result;
                    string authoremail          = UserBLL.Return_Value_UserId(_context, username, "email");
                    var    authormailpermission = Convert.ToByte(UserSettingsBLL.Get_Field_Value(_context, username, "isemail"));

                    if (authormailpermission == 1)
                    {
                        Send_Email("", username, authoremail, subject, content, url, tlst);
                    }
                }
                else
                {
                    // User Post Reply, Mail will be sent to autho, admin and all users who contribute replies
                    MailTemplateProcess(replyid, subject, content, url, username, groupid);
                }
            }
            catch (Exception ex)
            {
                ErrorLgBLL.Add(_context, "Mail Processing Error", "", ex.Message);
            }
        }
Пример #7
0
        public ActionResult action()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var data = JsonConvert.DeserializeObject <List <MailTemplateEntity> >(json);

            MailTemplateBLL.ProcessAction(_context, data);

            return(Ok(new { status = "success", message = SiteConfig.generalLocalizer["_records_processed"].Value }));
        }
Пример #8
0
        public async Task <ActionResult> Index()
        {
            var data = new MailTemplateEntity()
            {
                pagenumber = 1,
                type       = "-1",
                pagesize   = 20,
                order      = "id desc"
            };
            var _posts = await MailTemplateBLL.Load(_context, data);;

            return(Ok(new { posts = _posts, records = 434 }));
        }
Пример #9
0
        public async Task <ActionResult> load()
        {
            var json     = new StreamReader(Request.Body).ReadToEnd();
            var data     = JsonConvert.DeserializeObject <MailTemplateEntity>(json);
            var _posts   = await MailTemplateBLL.Load(_context, data);;
            var _records = 0;

            if (data.id == 0)
            {
                _records = await MailTemplateBLL.Count(_context, data);
            }
            return(Ok(new { posts = _posts, records = _records }));
        }
Пример #10
0
        public async Task <ActionResult> getinfo()
        {
            var json   = new StreamReader(Request.Body).ReadToEnd();
            var data   = JsonConvert.DeserializeObject <List <MailTemplateEntity> >(json);
            var _posts = await MailTemplateBLL.Load(_context, data[0]);

            if (_posts.Count > 0)
            {
                return(Ok(new { status = "success", posts = _posts[0] }));
            }
            else
            {
                return(Ok(new { status = "error", message = SiteConfig.generalLocalizer["_no_records"].Value }));
            }
        }
Пример #11
0
    private void LoadData(int id)
    {
        DataSet ds = MailTemplateBLL.Get_Value(id);

        if (ds.Tables[0].Rows.Count > 0)
        {
            lbl_key.Text         = ds.Tables[0].Rows[0]["templatekey"].ToString();
            lbl_tags.Text        = ds.Tables[0].Rows[0]["tags"].ToString();
            lbl_type.Text        = ds.Tables[0].Rows[0]["type"].ToString();
            lbl_description.Text = ds.Tables[0].Rows[0]["description"].ToString();
            lbl_subjecttags.Text = ds.Tables[0].Rows[0]["subjecttags"].ToString();
            txt_subject.Text     = ds.Tables[0].Rows[0]["subject"].ToString();
            txt_content.Value    = ds.Tables[0].Rows[0]["contents"].ToString();
        }
    }
Пример #12
0
    private void BindList()
    {
        DataSet ds = MailTemplateBLL.Get_Information(drp_sorttype.SelectedValue);

        if (ds.Tables[0].Rows.Count > 0)
        {
            Pagination_Process.Process_Pagination(MyList, rptPages, lnk_Prev, lnk_Next, 40, this.PageNumber, ds.Tables[0].DefaultView);
            pnl_main.Visible     = true;
            pnl_norecord.Visible = false;
        }
        else
        {
            pnl_main.Visible     = false;
            pnl_norecord.Visible = true;
        }
    }
Пример #13
0
    private void MailTemplateProcess(string emailaddress, string username, string url)
    {
        //if sending mail option enabled
        if (Config.isEmailEnabled())
        {
            System.Collections.Generic.List <Struct_MailTemplates> lst = MailTemplateBLL.Get_Record("FORPASS");
            if (lst.Count > 0)
            {
                string subject  = MailProcess.Process2(lst[0].Subject, "\\[username\\]", username);
                string contents = MailProcess.Process2(lst[0].Contents, "\\[username\\]", username);
                contents = MailProcess.Process2(contents, "\\[url\\]", url);

                MailProcess.Send_Mail(emailaddress, subject, contents);
            }
        }
    }
Пример #14
0
    private void MailTemplateProcess(string username)
    {
        //if sending mail option enabled
        if (Config.isEmailEnabled())
        {
            string emailaddress = members.Return_Value(username, "email");
            System.Collections.Generic.List <Struct_MailTemplates> lst = MailTemplateBLL.Get_Record("USRPRIVCHN");
            if (lst.Count > 0)
            {
                string subject  = MailProcess.Process2(lst[0].Subject, "\\[username\\]", username);
                string contents = MailProcess.Process2(lst[0].Contents, "\\[username\\]", username);

                MailProcess.Send_Mail(emailaddress, subject, contents);
            }
        }
    }
Пример #15
0
 private void ManageAccount_MailTemplateProcess(string username)
 {
     //if sending mail option enabled
     if (Jugnoon.Settings.Configs.SmtpSettings.enable_email)
     {
         string emailaddress = UserBLL.Return_Value_UserId(_context, username, "email");
         var    lst          = MailTemplateBLL.Get_Template(_context, "USRPASSCHN").Result;
         if (lst.Count > 0)
         {
             string subject  = MailProcess.Process2(lst[0].subject, "\\[username\\]", username);
             string contents = MailProcess.Process2(lst[0].contents, "\\[username\\]", username);
             // attach signature
             contents = MailProcess.Prepare_Email_Signature(contents);
             MailProcess.Send_Mail(emailaddress, subject, contents);
         }
     }
 }
Пример #16
0
    protected void btn_add_Click(object sender, System.EventArgs e)
    {
        string value = txt_content.Value;

        if (string.IsNullOrEmpty(value))
        {
            ShowMessage("Insert mail template content");
            return;
        }
        if (string.IsNullOrEmpty(txt_subject.Text))
        {
            ShowMessage("Insert subject of mail template");
            return;
        }
        MailTemplateBLL.Update_Record(this.TID, txt_subject.Text, value);

        Response.Redirect(Config.GetUrl("adm/sc/mail/Default.aspx?status=updated"));
    }
Пример #17
0
    // mail processing
    private void MailTemplateProcess(string emailaddress, string username, string password, string key)
    {
        //if sending mail option enabled
        if (Config.isEmailEnabled())
        {
            System.Collections.Generic.List <Struct_MailTemplates> lst = MailTemplateBLL.Get_Record("USRREG");
            if (lst.Count > 0)
            {
                string subject  = MailProcess.Process2(lst[0].Subject, "\\[username\\]", username);
                string contents = MailProcess.Process2(lst[0].Contents, "\\[username\\]", username);
                contents = MailProcess.Process2(contents, "\\[password\\]", password);
                string validation_url = Config.GetUrl("validate.aspx?key=" + key.Trim() + "&user="******"<a href=\"" + validation_url + "\">" + validation_url + "</a>";
                contents = MailProcess.Process2(contents, "\\[key_url\\]", url);

                MailProcess.Send_Mail(emailaddress, subject, contents);
            }
        }
    }
Пример #18
0
    // send mail to admin when new content added by user
    public static void Admin_New_Content_Added(string username, string contenttype, string url)
    {
        //if sending mail option enabled
        if (Config.isEmailEnabled())
        {
            System.Collections.Generic.List <Struct_MailTemplates> lst = MailTemplateBLL.Get_Record("USRAPRCNT");
            if (lst.Count > 0)
            {
                string subject = MailProcess.Process2(lst[0].Subject, "\\[username\\]", username);
                subject = MailProcess.Process2(subject, "\\[contenttype\\]", contenttype);
                string contents = MailProcess.Process2(lst[0].Contents, "\\[username\\]", username);
                subject  = MailProcess.Process2(subject, "\\[contenttype\\]", contenttype);
                contents = MailProcess.Process2(contents, "\\[url\\]", url);

                string emailaddress = Site_Settings.Admin_Mail;
                MailProcess.Send_Mail(emailaddress, subject, contents);
            }
        }
    }
Пример #19
0
    // ******************************
    // Mail Templates
    // ******************************

    // send mail to user when admin approved user posted content
    public static void User_Mail_Content_Action(string username, string contenttype, string url, string status)
    {
        //if sending mail option enabled
        if (Config.isEmailEnabled())
        {
            System.Collections.Generic.List <Struct_MailTemplates> lst = MailTemplateBLL.Get_Record("USRCNTAPP");
            if (lst.Count > 0)
            {
                string subject = MailProcess.Process2(lst[0].Subject, "\\[username\\]", username);
                subject = MailProcess.Process2(subject, "\\[status\\]", status);
                subject = MailProcess.Process2(subject, "\\[contenttype\\]", contenttype);
                string contents = MailProcess.Process2(lst[0].Contents, "\\[username\\]", username);
                contents = MailProcess.Process2(contents, "\\[contenttype\\]", contenttype);
                contents = MailProcess.Process2(contents, "\\[url\\]", url);
                contents = MailProcess.Process2(contents, "\\[status\\]", status);
                string emailaddress = members.Return_Value(username, "email");
                MailProcess.Send_Mail(emailaddress, subject, contents);
            }
        }
    }
Пример #20
0
 private void MailTemplateProcess(long tid, string subject, string content, string url, string username, long groupid)
 {
     //if sending mail option enabled
     if (Jugnoon.Settings.Configs.SmtpSettings.enable_email)
     {
         var lst = MailTemplateBLL.Get_Template(_context, "FORUMTREP").Result;
         if (lst.Count > 0)
         {
             string TopicAuthorusername = ForumTopicBLL.Return_Value(_context, tid, "username");
             //// send email to admin
             //string emailaddress = UserBLL.Return_Value(model.username, "email");
             //Send_Email(model.username,"admin", subject, content, url, lst);
             // send mail to all other usernames who already post topi on model content
             var cuserlist = UserBLL.LoadItems(_context, new MemberEntity()
             {
                 topicid = tid
             }).Result;
             if (cuserlist.Count > 0)
             {
                 int i = 0;
                 for (i = 0; i <= cuserlist.Count - 1; i++)
                 {
                     //if (cuserlist[i].isautomail == 1)
                     //{
                     if (cuserlist[i].UserName == TopicAuthorusername)
                     {
                         // topic author
                         GroupMailProcessTemplate(TopicAuthorusername, subject, username, cuserlist[i].Email, url, groupid);
                     }
                     else
                     {
                         // normal user
                         Send_Email(username, cuserlist[i].UserName, cuserlist[i].Email, subject, content, url, lst);
                     }
                     //}
                 }
             }
         }
     }
 }
Пример #21
0
        /// <summary>
        /// Send email notification to admin when new user signup
        /// </summary>
        /// <param name="emailSender"></param>
        /// <param name="context"></param>
        /// <param name="email"></param>
        /// <param name="username"></param>
        /// <returns></returns>
        public static Task SendEmailNotificationAsync(this IEmailSender emailSender, ApplicationDbContext context, string email, string username)
        {
            if (Settings.Configs.SmtpSettings.enable_email)
            {
                var lst = MailTemplateBLL.Get_Template(context, "USRREGADM").Result;
                if (lst.Count > 0)
                {
                    string subject = MailProcess.Process2(lst[0].subject, "\\[username\\]", username);
                    subject = MailProcess.Prepare_Email_Signature(subject);

                    string contents = MailProcess.Process2(lst[0].contents, "\\[username\\]", username);
                    contents = MailProcess.Process2(contents, "\\[email\\]", email);

                    // attach signature
                    contents = MailProcess.Prepare_Email_Signature(contents);

                    return(emailSender.SendEmailAsync(Jugnoon.Settings.Configs.GeneralSettings.admin_mail, subject, contents));
                }
            }

            return(Task.CompletedTask);
        }
Пример #22
0
        /// <summary>
        /// Send notification to user when email reset event completed successfully
        /// </summary>
        /// <param name="emailSender"></param>
        /// <param name="context"></param>
        /// <param name="email"></param>
        /// <param name="username"></param>
        /// <returns></returns>
        public static Task ChangeEmailResetCompletedAsync(this IEmailSender emailSender, ApplicationDbContext context, string email, string username)
        {
            if (Settings.Configs.SmtpSettings.enable_email)
            {
                if (username.Contains("@"))
                {
                    username = "******";
                }
                var lst = MailTemplateBLL.Get_Template(context, "USREMLCHNG").Result;
                if (lst.Count > 0)
                {
                    string subject = MailProcess.Process2(lst[0].subject, "\\[username\\]", username);
                    subject = MailProcess.Prepare_Email_Signature(subject);

                    string contents = MailProcess.Process2(lst[0].contents, "\\[username\\]", username);
                    contents = MailProcess.Prepare_Email_Signature(contents);

                    return(emailSender.SendEmailAsync(email, subject, contents));
                }
            }

            return(Task.CompletedTask);
        }
Пример #23
0
        public async Task <ActionResult> proc()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var data = JsonConvert.DeserializeObject <JGN_MailTemplates>(json);

            if (data.id > 0)
            {
                // Update Operation
                MailTemplateBLL.Update_Record(_context, data.id, data.subject, data.description, data.contents, data.tags, data.subjecttags);
            }
            else
            {
                // check whether template already exist
                if (MailTemplateBLL.CheckTemplate(_context, data.templatekey))
                {
                    return(Ok(new { status = "error", message = SiteConfig.generalLocalizer["_record_exist"].Value }));
                }
                // Add Operation
                data = await MailTemplateBLL.Add(_context, data);
            }

            return(Ok(new { status = "success", record = data, message = SiteConfig.generalLocalizer["_records_processed"].Value }));
        }